Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
7912 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

Thank you very much Niyas.

Post Terkait Replies Tampilan Aktivitas
1
Okt 23
1773
2
Okt 23
2011
3
Okt 23
8373
1
Sep 23
3169
2
Agu 23
3983