Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
7915 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

Thank you very much Niyas.

Post correlati Risposte Visualizzazioni Attività
1
ott 23
1774
2
ott 23
2012
3
ott 23
8382
1
set 23
3169
2
ago 23
3984