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

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # -*- coding: utf-8 -*-
  2. from openerp import api
  3. from openerp import models
  4. class ResPartnerStripEmail(models.Model):
  5. _inherit = 'res.partner'
  6. @api.multi
  7. def write(self, vals):
  8. for r in self:
  9. r.write_one(vals)
  10. @api.multi
  11. def write_one(self, vals):
  12. self.ensure_one()
  13. vals = self._check_email_field(vals)
  14. return super(ResPartnerStripEmail, self).write(vals)
  15. @api.model
  16. def create(self, vals):
  17. vals = self._check_email_field(vals)
  18. return super(ResPartnerStripEmail, self).create(vals)
  19. def _check_email_field(self, vals):
  20. if vals.get('email'):
  21. vals['email'] = vals['email'].strip()
  22. return vals