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.

54 lines
1.8 KiB

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