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.

22 lines
586 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
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class res_partner_strip_email(models.Model):
  4. _inherit = 'res.partner'
  5. @api.one
  6. def write(self, vals):
  7. vals = self._check_email_field(vals)
  8. return super(res_partner_strip_email, self).write(vals)
  9. @api.model
  10. def create(self, vals):
  11. vals = self._check_email_field(vals)
  12. return super(res_partner_strip_email, self).create(vals)
  13. def _check_email_field(self, vals):
  14. if vals.get('email'):
  15. vals['email'] = vals['email'].strip()
  16. return vals