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.

23 lines
588 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.one
  7. def write(self, vals):
  8. vals = self._check_email_field(vals)
  9. return super(ResPartnerStripEmail, self).write(vals)
  10. @api.model
  11. def create(self, vals):
  12. vals = self._check_email_field(vals)
  13. return super(ResPartnerStripEmail, self).create(vals)
  14. def _check_email_field(self, vals):
  15. if vals.get('email'):
  16. vals['email'] = vals['email'].strip()
  17. return vals