Openerp Message Output Dialog Box
2 answers
Raising osv.except_osv
does a few things:
1) Aborts the current processing (this is a python exception after all).
2) Forces OpenERP to rollback the current database transaction.
3) Calls OpenERP to display a dialog box to the user, not to flush the stack trace and present a "bad incident" message to the user.
For information exchange, we may return
warning = {
'title': 'Warning!',
'message' : 'Your message.'
}
return {'warning': warning}
But that won't work for other things like a button.
In your case, you can do
cr.commit()
raise osv.except_osv(_("Warning!"), _("Error"))
But calling cr.commit
explicitly in a business transaction will lead to serious problems.
Another way is to return the wizard with a warning message. This is what most people have used.
return {
'name': 'Provide your popup window name',
'view_type': 'form',
'view_mode': 'form',
'view_id': [res and res[1] or False],
'res_model': 'your.popup.model.name',
'context': "{}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'res_id': record_id or False,##please replace record_id and provide the id of the record to be opened
}
+2
source to share