helpdesk_workflow_template_sla.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # -*- coding: utf-8 -*-
  2. from odoo import fields, models
  3. from odoo.addons.helpdesk.models.helpdesk_ticket import TICKET_PRIORITY
  4. class HelpdeskWorkflowTemplateSLA(models.Model):
  5. _name = 'helpdesk.workflow.template.sla'
  6. _description = 'Workflow Template SLA Policy'
  7. _order = 'sequence, id'
  8. template_id = fields.Many2one(
  9. 'helpdesk.workflow.template',
  10. string='Template',
  11. required=True,
  12. ondelete='cascade',
  13. index=True
  14. )
  15. name = fields.Char(
  16. string='SLA Policy Name',
  17. required=True,
  18. translate=True,
  19. help='Name of the SLA policy'
  20. )
  21. description = fields.Html(
  22. string='Description',
  23. translate=True,
  24. help='Description of the SLA policy'
  25. )
  26. sequence = fields.Integer(
  27. string='Sequence',
  28. default=10,
  29. help='Order of SLA policies'
  30. )
  31. stage_template_id = fields.Many2one(
  32. 'helpdesk.workflow.template.stage',
  33. string='Target Stage',
  34. required=True,
  35. domain="[('template_id', '=', template_id)]",
  36. help='Minimum stage a ticket needs to reach in order to satisfy this SLA'
  37. )
  38. exclude_stage_template_ids = fields.Many2many(
  39. 'helpdesk.workflow.template.stage',
  40. 'workflow_template_sla_exclude_stage_rel',
  41. 'sla_template_id',
  42. 'stage_template_id',
  43. string='Excluding Stages',
  44. domain="[('template_id', '=', template_id), ('id', '!=', stage_template_id)]",
  45. help='Stages where time spent will NOT count towards the SLA deadline. '
  46. 'When a ticket is in these stages, the SLA timer is frozen. '
  47. 'Useful for stages like "On Hold" or "Waiting for Customer" where the ticket is waiting for external action.'
  48. )
  49. time = fields.Float(
  50. string='Within (hours)',
  51. required=True,
  52. default=0.0,
  53. help='Maximum number of working hours a ticket should take to reach the target stage'
  54. )
  55. priority = fields.Selection(
  56. TICKET_PRIORITY,
  57. string='Priority',
  58. default='0',
  59. required=True,
  60. help='Priority level for this SLA policy'
  61. )
  62. tag_ids = fields.Many2many(
  63. 'helpdesk.tag',
  64. string='Tags',
  65. help='Tags that trigger this SLA policy (optional, if empty applies to all tickets)'
  66. )