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.

53 lines
1.7 KiB

  1. # Copyright 2017 Eficent Business and IT Consulting Services S.L.
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class TierDefinition(models.Model):
  5. _name = "tier.definition"
  6. _rec_name = "model_id"
  7. @api.model
  8. def _get_tier_validation_model_names(self):
  9. res = []
  10. return res
  11. model_id = fields.Many2one(
  12. comodel_name="ir.model",
  13. string="Referenced Model",
  14. )
  15. model = fields.Char(
  16. related='model_id.model', index=True, store=True,
  17. )
  18. review_type = fields.Selection(
  19. string="Validated by", default="individual",
  20. selection=[("individual", "Specific user"),
  21. ("group", "Any user in a specific group.")]
  22. )
  23. reviewer_id = fields.Many2one(
  24. comodel_name="res.users", string="Reviewer",
  25. )
  26. reviewer_group_id = fields.Many2one(
  27. comodel_name="res.groups", string="Reviewer group",
  28. )
  29. python_code = fields.Text(
  30. string='Tier Definition Expression',
  31. help="Write Python code that defines when this tier confirmation "
  32. "will be needed. The result of executing the expresion must be "
  33. "a boolean.",
  34. default="""# Available locals:\n# - rec: current record""",
  35. )
  36. active = fields.Boolean(default=True)
  37. sequence = fields.Integer(default=30)
  38. company_id = fields.Many2one(
  39. comodel_name="res.company", string="Company",
  40. default=lambda self: self.env["res.company"]._company_default_get(
  41. "tier.definition"),
  42. )
  43. @api.onchange('model_id')
  44. def onchange_model_id(self):
  45. return {'domain': {
  46. 'model_id': [
  47. ('model', 'in', self._get_tier_validation_model_names())]}}