Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
13715 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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(); } }); }); },

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
heinäk. 25
232
2
heinäk. 25
925
4
heinäk. 25
777
1
heinäk. 25
111
2
heinäk. 25
203