Odoo Help


Email validation in openerp 7.0 ?

on 8/8/13, 12:25 PM 3,773 views

how to achieve email validation in openerp 7.0 and what is the use of widget="email"

Akhilesh Gupta
On 2/18/14, 1:25 AM

In .py file write this method..........

import re

def  ValidateEmail(self, cr, uid, ids, email):
        if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
            return True
            raise osv.except_osv('Invalid Email', 'Please enter a valid email address')

In view.xml file write this line

<field name="email" on_change="ValidateEmail(email)"/>
Yassine TEIMI
On 3/19/15, 7:41 AM

@ Akki Modi

You should add a condition when the field email is empty, because onchange methods are executed even during a record creation, so when it find it null, because you have not filled values yet, the onchange method will return an error !

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/8/13, 12:25 PM
Seen: 3773 times
Last updated: 3/19/15, 7:41 AM