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.

33 lines
1004 B

  1. # Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
  2. # © 2017-Apertoso N.V. (<http://www.apertoso.be>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. import logging
  6. _logger = logging.getLogger(__name__)
  7. class ResPartner(models.Model):
  8. """Partner with birth date in date format."""
  9. _inherit = "res.partner"
  10. # New birthdate field in date format
  11. birthdate_date = fields.Date("Birthdate")
  12. # Make the old Char field to reflect the new Date field
  13. birthdate = fields.Char(
  14. compute="_birthdate_compute",
  15. inverse="_birthdate_inverse",
  16. store=True)
  17. @api.one
  18. @api.depends("birthdate_date")
  19. def _birthdate_compute(self):
  20. """Store a string of the new date in the old field."""
  21. self.birthdate = self.birthdate_date
  22. @api.one
  23. def _birthdate_inverse(self):
  24. """Convert the old Char date to the new Date format."""
  25. self.birthdate_date = self.birthdate