This question has been flagged
2 Replies
6877 Views

Hello,

I would like to implement a notification like "Globe" (as it appears when required fields are empty and placed [the Following fields are invalid:]) in a method on_change. Examining the code openERP only found a place where was implemented this type of message (addons / web / static / src / js / view_form.js: 867). I ask, you can use this notification type for a method on_change?.

Avatar
Discard
Author Best Answer

Thank you very much for your answer Alex Malone. Upload a screenshot to my dropbox account to make it more clear what kind of notification I'm trying to implement,

dl.dropboxusercontent.com/u/ 49982149 /OpenERP/Globe_Message.PNG

Avatar
Discard
Best Answer

Not sure if this will answer your question or not as I don't know what globe notifications are, but in my system we use two types of notifications:

1) raise

e.g.

raise osv.except_osv(_('Cannot Send E-mail'), _('No To address specified'))

This type of error message gets displayed as soon as the code is reached and will cause the system to roll back, i.e. any code run in your on_change function will be reversed / uncompleted if you use a raise notification. We use these for critical errors.

2) Warnings

This is probably what you want to use in your on_change method. In your on_change method you can return warning as part of the dictionary that gets returned. The warning message will be displayed to the user but will not interupt the running of any other code and wont roll back. The warning is returned in the following form:

return {'value': {}, 'warning': {'title': 'Warning Title Here', 'message': 'Your warning message here'}}

A good example of when we use this is when we are providing quotes. We have an on change method that works out the price based on quantity and unit price. Our on change method also checks for negative values and will warn the user about the negative value whilst also resetting the negative value.

Hope this helps.

Avatar
Discard