How to validate email in odoo 9?plz send the code.
0
3 Answers
Best Answer
Try the following code:
import re from openerp.exceptions import except_orm from openerp.tools.translate import _
Within the class, define the following method:
@api.one
@api.onchange('emai')
def validateEmail(selfl):
if self.email:
if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
return True
else:
raise raise except_orm(_('Invalid Email'), _("Please enter a valid email address"))You also need to override create and write method to call the validateEmail method.