Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
10993 Näkymät

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
Hylkää
Tekijä Paras vastaus

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
Hylkää
Paras vastaus

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
Hylkää
Tekijä

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)

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
maalisk. 15
3660
1
tammik. 16
5244
0
syysk. 15
3760
0
elok. 15
4474
1
heinäk. 15
7777