Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
7313 Visualizzazioni

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

Avatar
Abbandona
Risposta migliore

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)"/>
Avatar
Abbandona
Risposta migliore

@ 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 !

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
ago 19
2616
4
lug 20
6007
1
lug 25
1079
5
mag 25
18545
0
apr 25
1222