I need to discard the change user made when an exception occurred, to go back to the value when input is valid.
For example I have 2 field check_in & check_out as Date type. I need to check the check_in must be smaller than check_out. When the check_in is bigger than check_out, an exception dialog shows. When the user closes the exception dialog, I need to discard the change for check_in.
@api.onchange('check_in', 'check_out')
def validate_check_in(self):
for rec in self:
if rec.check_in > rec.check_out:
raise ValidationError("Not valid check in and check out")