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
|Asked: 4/18/16, 6:34 PM|
|Seen: 132 times|
|Last updated: 4/19/16, 2:04 AM|