Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to display an error dialog after raising ValidationError

By
Simon Lee
on 8/11/16, 1:11 AM 242 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/11/16, 1:11 AM
Seen: 242 times
Last updated: 8/11/16, 9:20 AM