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.

37 lines
1.4 KiB

  1. # Copyright 2019 Creu Blanca
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import fields, api, models
  4. class TierDefinition(models.Model):
  5. _inherit = 'tier.definition'
  6. python_code = fields.Text(
  7. string='Tier Definition Expression',
  8. help="Write Python code that defines when this tier confirmation "
  9. "will be needed. The result of executing the expresion must be "
  10. "a boolean.",
  11. default="""# Available locals:\n# - rec: current record""",
  12. )
  13. definition_type = fields.Selection(
  14. selection_add=[('formula', 'Formula')]
  15. )
  16. reviewer_expression = fields.Text(
  17. string='Review Expression',
  18. help="Write Python code that defines the reviewer. "
  19. "The result of executing the expression must be a res.users "
  20. "recordset.",
  21. default="# Available locals:\n# - rec: current record\n"
  22. "# - Expects a recordset of res.users",
  23. )
  24. review_type = fields.Selection(
  25. selection_add=[("expression", "Python Expression")]
  26. )
  27. @api.onchange('review_type')
  28. def onchange_review_type(self):
  29. super(TierDefinition, self).onchange_review_type()
  30. self.reviewer_expression = "# Available locals:\n" \
  31. "# - rec: current record\n" \
  32. "# - Expects a recordset of res.users"