On_change_notify issue

Hi ,

I try to add a simple on_change_notify() to the sale_subscription module. I extend class Subscription with:

 @fields.depends('party')
    def on_change_notify(self):
        notifications = super().on_change_notify()
........
..
            count = Subscription.search_count(domain)
            if count:
                notifications.append((
                    'warning',
                    'Here a wonderful warning'
                ))
        return notifications

The code is working, but the message in Version 8.0 with corresponding Sao client, appears for about 100 milliseconds and disappears again. It just a blink..

Am I missing something?

Thanks for Hints Jakob

Hi Jakob,

I think the warning type is fine.

In Sao, each on_change_notify result refreshes the notification area before displaying the returned messages. If another on_change_notify call occurs immediately afterwards and returns an empty list, the previous warning will briefly appear and then disappear.

I would check the browser Network tab to see whether on_change_notify is called more than once when changing party, and what each response contains.

Also ensure that fields.depends includes every field used to compute the warning, especially fields modified by on_change_party(). Otherwise a subsequent onchange may evaluate the condition with different values and return no notification.

If you can share the complete method and domain, it should be easier to identify which dependency or onchange causes the second result.

Indeed it is a bug in the clients, see Notifications are cleared on each display call (#15012) · Issues · Tryton / Tryton · GitLab.