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.

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