Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
7840 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor

Thank you very much Niyas.

Related Posts Odpovědi Zobrazení Aktivita
1
říj 23
1668
2
říj 23
1897
3
říj 23
8146
1
zář 23
3024
2
srp 23
3837