Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I need to add a constraint in a phone number, like not having spaces between the number and the phone number must not be more longer than ten number.
I want to have this for example : 00412025678 and not this 004 12 02 56 78
Where and How can I add this contraint ? I use Odoo9.
Thank you for your help
you can try this:
from openerp.exceptions import UserError, RedirectWarning, ValidationError
@api.constrains('YOUR FIELD NAME')
# here is your code
if ' ' in self.phone or len(self.phone) >= 10:
hope this will help you.
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 platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 4/18/16, 6:34 PM|
|Seen: 178 times|
|Last updated: 4/19/16, 2:04 AM|