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.

31 lines
968 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 SYLEAM
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from .. import common
  5. from odoo import models, api
  6. class Base(models.AbstractModel):
  7. _inherit = 'base'
  8. @api.multi
  9. def write(self, vals):
  10. fields_to_convert = common.get_phone_fields(self, vals)
  11. if fields_to_convert:
  12. for record in self:
  13. loc_vals = common.convert_all_phone_fields(
  14. record, vals, fields_to_convert)
  15. super(Base, record).write(loc_vals)
  16. return True
  17. else:
  18. return super(Base, self).write(vals)
  19. @api.model
  20. @api.returns('self', lambda value: value.id)
  21. def create(self, vals):
  22. fields_to_convert = common.get_phone_fields(self, vals)
  23. if fields_to_convert:
  24. vals = common.convert_all_phone_fields(
  25. self, vals, fields_to_convert)
  26. return super(Base, self).create(vals)