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.

55 lines
1.8 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. name = fields.Char(related="definition_id.name", readonly=True)
  7. status = fields.Selection(
  8. selection=[("pending", "Pending"),
  9. ("rejected", "Rejected"),
  10. ("approved", "Approved")],
  11. default="pending",
  12. )
  13. model = fields.Char(string='Related Document Model', index=True)
  14. res_id = fields.Integer(string='Related Document ID', index=True)
  15. definition_id = fields.Many2one(
  16. comodel_name="tier.definition",
  17. )
  18. review_type = fields.Selection(
  19. related="definition_id.review_type", readonly=True,
  20. )
  21. reviewer_id = fields.Many2one(
  22. related="definition_id.reviewer_id", readonly=True,
  23. )
  24. reviewer_group_id = fields.Many2one(
  25. related="definition_id.reviewer_group_id", readonly=True,
  26. )
  27. reviewer_ids = fields.Many2many(
  28. string="Reviewers", comodel_name="res.users",
  29. compute="_compute_reviewer_ids", store=True,
  30. )
  31. sequence = fields.Integer(string="Tier")
  32. done_by = fields.Many2one(
  33. comodel_name="res.users",
  34. )
  35. requested_by = fields.Many2one(
  36. comodel_name="res.users",
  37. )
  38. reviewed_date = fields.Datetime(string='Validation Date')
  39. @api.model
  40. def _get_reviewer_fields(self):
  41. return ['reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users']
  42. @api.multi
  43. @api.depends(lambda self: self._get_reviewer_fields())
  44. def _compute_reviewer_ids(self):
  45. for rec in self:
  46. rec.reviewer_ids = rec._get_reviewers()
  47. def _get_reviewers(self):
  48. return self.reviewer_id + self.reviewer_group_id.users