helpdesk_team_collaborator.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class HelpdeskTeamCollaborator(models.Model):
  5. _name = 'helpdesk.team.collaborator'
  6. _description = 'Collaborators in helpdesk team shared'
  7. team_id = fields.Many2one(
  8. 'helpdesk.team',
  9. string='Helpdesk Team',
  10. required=True,
  11. readonly=True,
  12. ondelete='cascade',
  13. export_string_translation=False
  14. )
  15. partner_id = fields.Many2one(
  16. 'res.partner',
  17. string='Collaborator',
  18. required=True,
  19. readonly=True,
  20. export_string_translation=False
  21. )
  22. partner_email = fields.Char(
  23. related='partner_id.email',
  24. string='Email',
  25. readonly=True,
  26. export_string_translation=False
  27. )
  28. access_mode = fields.Selection(
  29. [
  30. ('admin', 'Administrator'),
  31. ('user_all', 'User - All Tickets'),
  32. ('user_own', 'User - Own Tickets'),
  33. ],
  34. string='Access Mode',
  35. required=True,
  36. default='user_own',
  37. help="Administrator: can view all tickets and manage other users.\n"
  38. "User - All Tickets: can view all tickets and create own tickets.\n"
  39. "User - Own Tickets: can only create and view own tickets."
  40. )
  41. _sql_constraints = [
  42. (
  43. 'unique_collaborator',
  44. 'UNIQUE(team_id, partner_id)',
  45. 'A collaborator cannot be selected more than once in the helpdesk team sharing access. Please remove duplicate(s) and try again.'
  46. ),
  47. ]
  48. _rec_name = 'partner_id'