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.

41 lines
1.4 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 TierReview(models.Model):
  6. _name = "tier.review"
  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. @api.multi
  33. @api.depends('reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users')
  34. def _compute_reviewer_ids(self):
  35. for rec in self:
  36. rec.reviewer_ids = rec.reviewer_id + rec.reviewer_group_id.users