This question has been flagged
2 Replies
12698 Views

I want to customize warning message box. E.g. I have one _constraints options on one column. I want to customize head and body of custom message. Of course I know that I can set message in _constraints but I want to control the whole message box.

And another subject. Can I add my own message box after user click on my button prepared in my own module? E.g. I want show message "Hi! Your data were saved successfully" after user click my button "proceed"

Avatar
Discard
Best Answer

though it's a "dirty" solution, the most common way in OpenERP to pop up warning messages is to raise an exception, like:

raise osv.except_osv(_('Hi!'), _('Your data were saved successfully'))

Inside on_change methods, but only in this case afaik, you can "return" the warning message by doing:

return {'warning': {
                    'title': _('Hi!'),
                    'message':  _('Your data were saved successfully'),
                    }
                }
Avatar
Discard

I think there is another mechanism, like the one used when clicking "Reset Password" on a user, but I do not know how it works exactly.

Hi Yes sure you can raise Alert Message when saving record through JS script it is possible you have to write single line code in path addons/web/static/src/js/viewform.js on_button_save: function() { var self = this; return this.save().done(function(result){ if (!confirm(_t("The record has been saved"))) { return false; } self.trigger("save", result); self.reload().then(function() { self.to_view_mode(); var parent = self.ViewManager.ActionManager.getParent(); if(parent){ parent.menu.do_reload_needaction(); } }); }); },