Odoo Help

Welcome!

This community 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.

0

Email validation in openerp 7.0 ?

By
Maniganda
on 8/8/13, 12:25 PM 2,917 views

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

3
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
        else:
            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)"/>
0
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 !

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!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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