Help

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Validate email

Avatar
poornima

How to validate email in odoo 9?plz send the code.

Avatar
Discard
3 Answers
0
Avatar
Captcha
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.
Avatar
Discard
0
Avatar
poornima
Best Answer

no i mean email field validation in contacts details form.

Avatar
Discard
0
Best Answer

What context did you mean about "validate email in odoo 9"? Did you want to know about registration email validation?

Avatar
Discard

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!