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.

27 lines
802 B

  1. # Copyright 2019-2020: Druidoo (<https://www.druidoo.io>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import _, api, fields, models
  4. from odoo.exceptions import ValidationError
  5. from .ffck_membership_type import RANGES
  6. class ResPartnerAgeRange(models.Model):
  7. _inherit = "res.partner.age.range"
  8. name = fields.Char(translate=True)
  9. age_range = fields.Selection(
  10. selection=RANGES,
  11. string="Global range",
  12. compute="_get_age_range",
  13. store=True,
  14. )
  15. active = fields.Boolean(string="Active", default=True)
  16. @api.depends("age_to")
  17. def _get_age_range(self):
  18. for range in self:
  19. if range.age_to <= 18:
  20. range.age_range = "young"
  21. else:
  22. range.age_range = "adult"