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
0
3
3,651

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

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

no i mean email field validation in contacts details form.

Avatar
poornima
Comment Share
Avatar
poornima
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?

Comment Share
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!

Q&A Forum Regulations

Forum Regulations

By using the FAQ Forum on ERPOnline.vn website, you unconditionally agree to the following terms:

    1. Q&A Forum is a discussion environment to support each other in Odoo/ERPOnline implementation, in the spirit of "community support community", with internet address at: https://www.erponline.vn/forum/hoi-dap-7

    2. You are thoroughly responsible for the content submitted by you.

    3. DO NOT use the Q&A Forum for any activities that violate Vietnamese law and International Conventions to which Vietnam is a participant.

    4. DO NOT post content that is offensive, defamatory, or discredits other individuals or legal entities.

    5. DO NOT post advertisements or advertising content.

    6. DO NOT post content that is not related to management software and ERP in general as well as OpenERP and ERPOnline.vn in particular.

    7. DO NOT post copyrighted content or content, materials, products protected by Intellectual Property law without the written consent of the author.

    8. DO NOT embed images from other websites.

    9. You agree that all options, solutions, answers in the Q&A section on ERPOnline.vn website are for reference only. ERPOnline.vn website will not be liable if you have any damage when applying the plans given in the Q&A section on ERPOnline.vn website.

These terms and conditions may be amended to suit reality at any time without prior notice.