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.

67 lines
1.9 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. _description = "Tier Definition"
  7. @api.model
  8. def _get_default_name(self):
  9. return "New Tier Validation"
  10. @api.model
  11. def _get_tier_validation_model_names(self):
  12. res = []
  13. return res
  14. name = fields.Char(
  15. 'Description', required=True, default=_get_default_name)
  16. model_id = fields.Many2one(
  17. comodel_name="ir.model",
  18. string="Referenced Model",
  19. )
  20. model = fields.Char(
  21. related='model_id.model', index=True, store=True,
  22. )
  23. review_type = fields.Selection(
  24. string="Validated by", default="individual",
  25. selection=[
  26. ("individual", "Specific user"),
  27. ("group", "Any user in a specific group."),
  28. ]
  29. )
  30. reviewer_id = fields.Many2one(
  31. comodel_name="res.users", string="Reviewer",
  32. )
  33. reviewer_group_id = fields.Many2one(
  34. comodel_name="res.groups", string="Reviewer group",
  35. )
  36. definition_type = fields.Selection(
  37. string="Definition",
  38. selection=[
  39. ('domain', 'Domain'),
  40. ],
  41. default='domain',
  42. )
  43. definition_domain = fields.Char()
  44. active = fields.Boolean(default=True)
  45. sequence = fields.Integer(default=30)
  46. company_id = fields.Many2one(
  47. comodel_name="res.company", string="Company",
  48. default=lambda self: self.env["res.company"]._company_default_get(
  49. "tier.definition"),
  50. )
  51. @api.onchange('model_id')
  52. def onchange_model_id(self):
  53. return {'domain': {
  54. 'model_id': [
  55. ('model', 'in', self._get_tier_validation_model_names())]}}
  56. @api.onchange('review_type')
  57. def onchange_review_type(self):
  58. self.reviewer_id = None
  59. self.reviewer_group_id = None