İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
10992 Görünümler

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
Vazgeç
Üretici En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

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)

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Mar 15
3660
1
Oca 16
5244
0
Eyl 15
3759
0
Ağu 15
4474
1
Tem 15
7777