# -*- coding: utf-8 -*- from odoo import fields, models from odoo.addons.helpdesk.models.helpdesk_ticket import TICKET_PRIORITY class HelpdeskWorkflowTemplateSLA(models.Model): _name = 'helpdesk.workflow.template.sla' _description = 'Workflow Template SLA Policy' _order = 'sequence, id' template_id = fields.Many2one( 'helpdesk.workflow.template', string='Template', required=True, ondelete='cascade', index=True ) name = fields.Char( string='SLA Policy Name', required=True, translate=True, help='Name of the SLA policy' ) description = fields.Html( string='Description', translate=True, help='Description of the SLA policy' ) sequence = fields.Integer( string='Sequence', default=10, help='Order of SLA policies' ) stage_template_id = fields.Many2one( 'helpdesk.workflow.template.stage', string='Target Stage', required=True, domain="[('template_id', '=', template_id)]", help='Minimum stage a ticket needs to reach in order to satisfy this SLA' ) exclude_stage_template_ids = fields.Many2many( 'helpdesk.workflow.template.stage', 'workflow_template_sla_exclude_stage_rel', 'sla_template_id', 'stage_template_id', string='Excluding Stages', domain="[('template_id', '=', template_id), ('id', '!=', stage_template_id)]", help='Stages where time spent will NOT count towards the SLA deadline. ' 'When a ticket is in these stages, the SLA timer is frozen. ' 'Useful for stages like "On Hold" or "Waiting for Customer" where the ticket is waiting for external action.' ) time = fields.Float( string='Within (hours)', required=True, default=0.0, help='Maximum number of working hours a ticket should take to reach the target stage' ) priority = fields.Selection( TICKET_PRIORITY, string='Priority', default='0', required=True, help='Priority level for this SLA policy' ) tag_ids = fields.Many2many( 'helpdesk.tag', string='Tags', help='Tags that trigger this SLA policy (optional, if empty applies to all tickets)' )