Reputation: 820
I have a model in odoo with a fields.Date attribute (expiration_date). How can I add a constraint to that field to check that any date entered by the user must be after a sertain date (like january 2016)
Upvotes: 0
Views: 846
Reputation: 126
You have to use user defined constraint to achieve this. Suppose, that certain date is Today.
@api.constrains('expiration_date')
def _check_expiration_date(self):
if self.expiration_date <= datetime.today():
raise ValidationError('Expiration date must be after today.')
Upvotes: 2