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.

45 lines
1.5 KiB

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