Odoo Help


How to Pass value while raising exception

Md. Tanzilul Hasan Khan
on 8/15/16, 6:23 AM 1,110 views

I have a scenario where I am raising exception in some conditions. But I need to make some fields 'Blank' or pass value '0' if the exception occurs.

I am using @api.onchange method and have tried following ways but none of them worked:


self.holiday_status_id = False
raise except_orm('No Joining Date!', 'There is no joining date defined for this employee')


res = {'warning':{'title':_('No Joining Date!'),
            'message':_('There is no joining date defined for this employee')},
return res



Ok I got this. As I am using onchange method I have to use the 'Warning' like this:

                self.holiday_status_id = False
return {'warning': {
'title': "Warning",
'message': "There is no joining date defined for this employee",

David Baramidze
On 8/15/16, 9:21 AM

Hello, use this:

from openerp.exceptions import except_orm, Warning, RedirectWarning
raise except_orm('Warning', warning_message)
raise Warning(warning_message)
raise RedirectWarning(warning_message, True, _('continue'))

I am not sure about your answer. I have used except_orm and Warning but result is same. It only shows the warning but value doesn't get updated.

Md. Tanzilul Hasan Khan
on 8/15/16, 9:31 AM

please show me full code.


def _funct_name(self):

if self.your_field == False:

self.another_field = ''

except_orm('Warning', warning_message)

David Baramidze
on 8/15/16, 9:49 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/15/16, 6:23 AM
Seen: 1110 times
Last updated: 8/16/16, 2:36 AM