Search code examples
odoo-10validationerror

Validation Error in ODOO


How to stop raising validation error in ODOO 10 For example in project.py file I want to stop raising this validation error :

@api.constrains('date_start', 'date_end')
def _check_dates(self):
    if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
        raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))

Solution

  • You can disable that warning by overriding the function. Try below code,

    @api.constrains('date_start', 'date_end')
    def _check_dates(self):
        if any(self.filtered(lambda task: task.date_start and task.date_end and task.date_start > task.date_end)):
           pass;
           #raise ValidationError(_('Error ! Task starting date must be lower than its ending date.'))
    

    Hope it will help you.