This question has been flagged
4522 Views

I am using odoo 9. I added a field "serial_no" to the purchase_order_line model. When the user make changes to the serial_no, before saving, I would like to check if the serial_no is valid. If not, it will display an error message in a dialog box and prevent the record from saving.

My code is as followed:

@api.constrains('serial_no')

def _check_serial_no(self):

    raise ValidationError('Serial no is not valid')

The above code is executed when openerp tried to save the record and did raise the ValidationError. But the error dialog is not displayed. Please advise how I can display the dialog box??? Do I need to change something on the settings? If yes, please advise what I need to set? Thanks.

Simon Lee

Avatar
Discard