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

# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from .ffck_membership_type import RANGES
class ResPartnerAgeRange(models.Model):
_inherit = "res.partner.age.range"
name = fields.Char(translate=True)
age_range = fields.Selection(
selection=RANGES,
string="Global range",
compute="_get_age_range",
store=True,
)
active = fields.Boolean(string="Active", default=True)
@api.depends("age_to")
def _get_age_range(self):
for range in self:
if range.age_to <= 18:
range.age_range = "young"
else:
range.age_range = "adult"