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.

38 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
  3. # License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html
  4. from openerp import api, fields, models
  5. class CustomInfoOption(models.Model):
  6. _description = "Available options for a custom property"
  7. _name = "custom.info.option"
  8. _order = "name"
  9. name = fields.Char(index=True, translate=True, required=True)
  10. property_ids = fields.Many2many(
  11. comodel_name="custom.info.property",
  12. string="Properties",
  13. help="Properties where this option is enabled.",
  14. )
  15. value_ids = fields.One2many(
  16. comodel_name="custom.info.value",
  17. inverse_name="value_id",
  18. string="Values",
  19. help="Values that have set this option.",
  20. )
  21. @api.multi
  22. def check_access_rule(self, operation):
  23. """You access an option if you access at least one property."""
  24. last = None
  25. for prop in self.mapped("property_ids"):
  26. try:
  27. prop.check_access_rule(operation)
  28. return
  29. except Exception as last:
  30. pass
  31. if last:
  32. raise last
  33. return super(CustomInfoOption, self).check_access_rule(operation)