Skip to Content
Menu
This question has been flagged
3 Replies
9913 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:

1. 

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

2.

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

Thanks.


Avatar
Discard
Author Best Answer

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",
}
}


Avatar
Discard
Best Answer

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'))
Avatar
Discard
Author

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.

please show me full code.

@api.onchange('your_field')

def _funct_name(self):

if self.your_field == False:

self.another_field = ''

except_orm('Warning', warning_message)

Related Posts Replies Views Activity
0
Mar 15
2755
1
Jan 16
4099
0
Sep 15
2777
0
Aug 15
3640
1
Jul 15
6787