Please let me know , how to prevent record getting saved when user enters invalid email address. Right now system displays warning message for invalid email address which is a
You need to modify your create write and validate functions.I hope your validateemail method is correct.Whenever the re.match is None, then warning will be showed.
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:
raise osv.except_osv('Invalid Email', 'Please enter a valid email address')
return True
def create(self, cr, uid,values,context=None):
if 'email' in values:
self.ValidateEmail(cr,uid,[],values['email'])
res = super(latest_base,self).create(cr,uid,values,context=context)
return res
def write(self, cr, uid, ids, values, context=None):
if 'email' in values:
self.ValidateEmail(cr,uid,ids,values['email'])
res = super(latest_base, self).write(cr, uid, ids, values, context=context)
return res