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.

40 lines
1.4 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 TierReview(models.Model):
  5. _name = "tier.review"
  6. status = fields.Selection(
  7. selection=[("pending", "Pending"),
  8. ("rejected", "Rejected"),
  9. ("approved", "Approved")],
  10. default="pending",
  11. )
  12. model = fields.Char(string='Related Document Model', index=True)
  13. res_id = fields.Integer(string='Related Document ID', index=True)
  14. definition_id = fields.Many2one(
  15. comodel_name="tier.definition",
  16. )
  17. review_type = fields.Selection(
  18. related="definition_id.review_type", readonly=True,
  19. )
  20. reviewer_id = fields.Many2one(
  21. related="definition_id.reviewer_id", readonly=True,
  22. )
  23. reviewer_group_id = fields.Many2one(
  24. related="definition_id.reviewer_group_id", readonly=True,
  25. )
  26. reviewer_ids = fields.Many2many(
  27. string="Reviewers", comodel_name="res.users",
  28. compute="_compute_reviewer_ids", store=True,
  29. )
  30. sequence = fields.Integer(string="Tier")
  31. @api.multi
  32. @api.depends('reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users')
  33. def _compute_reviewer_ids(self):
  34. for rec in self:
  35. rec.reviewer_ids = rec.reviewer_id + rec.reviewer_group_id.users