İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
8070 Görünümler

Hello everyone,

On Odoo v12, If I enter:

@api.onchange('date')if self.date > date.today():
    raise ValidationError(('Error: Check your date!' ))

The code runs fine and date values are checked for the condition.

If I enter:

@api.onchange('date')if self.date > date.today() or self.date == False:
    raise ValidationError(('Error: Check your date!' ))

I've got the error:

TypeError: '>' not supported between instances of 'bool' and 'datetime.date'

Also tried with if self.date > date.today() or self.date == "" with no luck.

Can anyone help me please?

Thank you in advance

Avatar
Vazgeç
En İyi Yanıt

Hi,

Update the code like this,


@api.onchange('date')
def change_date(self):
if self.date and self.date > date.today():
raise ValidationError(_('Error: Check your date!'))


Thanks

Avatar
Vazgeç
Üretici

Thank you very much Niyas.

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eki 23
2011
2
Eki 23
2209
3
Eki 23
8804
1
Eyl 23
3324
2
Ağu 23
4233