Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
10995 Vizualizări

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.


Imagine profil
Abandonează
Autor Cel mai bun răspuns

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


Imagine profil
Abandonează
Cel mai bun răspuns

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'))
Imagine profil
Abandonează
Autor

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 Răspunsuri Vizualizări Activitate
0
mar. 15
3660
1
ian. 16
5246
0
sept. 15
3762
0
aug. 15
4475
1
iul. 15
7777