You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
716 B

# -*- coding: utf-8 -*-
from openerp import api
from openerp import models
class ResPartnerStripEmail(models.Model):
_inherit = 'res.partner'
@api.multi
def write(self, vals):
for r in self:
r.write_one(vals)
@api.multi
def write_one(self, vals):
self.ensure_one()
vals = self._check_email_field(vals)
return super(ResPartnerStripEmail, self).write(vals)
@api.model
def create(self, vals):
vals = self._check_email_field(vals)
return super(ResPartnerStripEmail, self).create(vals)
def _check_email_field(self, vals):
if vals.get('email'):
vals['email'] = vals['email'].strip()
return vals