Reputation: 29
I would like to know how to raise an error when I open a window in Odoo.
For example, I open Sales window, and it'll raise an error or warning like "Hello" or anything else.
I know to use exception like:
from openerp.osv import osv,fields
from openerp.tools.translate import _
from openerp import pooler
from openerp.exceptions import except_orm`
raise osv.except_osv(_('Hello'), _('Hello World'))
but I don't know where should I put the code to raise that.
Upvotes: 1
Views: 983
Reputation: 4174
Use default_get
method, It will execute whenever click on the CREATE
button.
Add a field in list/form view
as compute
field, and add raise osv.except_osv(_('Hello'), _('Hello World'))
in compute function.
For a button action. define a function and call it in button definition.
<button name='function_name' type='object'/>
Upvotes: 1