Odoo modules extending contacts / partners
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.

28 lines
817 B

  1. # -*- coding: utf-8 -*-
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. from odoo import fields, models, api
  4. class ResCountryState(models.Model):
  5. _inherit = "res.country.state"
  6. majority_age = fields.Integer(
  7. string="Majority age",
  8. compute="_get_country_age",
  9. inverse="_set_standalone_age",
  10. store=True,
  11. readonly=False,
  12. )
  13. same_country_age = fields.Boolean(
  14. string="Same age as country",
  15. default=True,
  16. )
  17. @api.depends("country_id", "country_id.majority_age")
  18. def _get_country_age(self):
  19. for state in self.filtered("same_country_age"):
  20. state.majority_age = state.country_id.majority_age
  21. def _set_standalone_age(self):
  22. for state in self:
  23. state.same_country_age = False