|
@@ -104,3 +104,44 @@ class HelpdeskTicket(models.Model):
|
|
|
if not self.team_id or not self.team_id.template_id:
|
|
if not self.team_id or not self.team_id.template_id:
|
|
|
return self.env['helpdesk.template.field']
|
|
return self.env['helpdesk.template.field']
|
|
|
return self.team_id.template_id.field_ids.sorted('sequence')
|
|
return self.team_id.template_id.field_ids.sorted('sequence')
|
|
|
|
|
+
|
|
|
|
|
+ @api.onchange('request_type_id', 'business_impact')
|
|
|
|
|
+ def _onchange_compute_priority(self):
|
|
|
|
|
+ """
|
|
|
|
|
+ Auto-calculate priority based on request type and business impact.
|
|
|
|
|
+ Only applies when both fields have values.
|
|
|
|
|
+
|
|
|
|
|
+ Mapping:
|
|
|
|
|
+ - Incident + Critical = 3 (Urgent)
|
|
|
|
|
+ - Incident + High = 2 (High)
|
|
|
|
|
+ - Incident + Normal = 1 (Normal)
|
|
|
|
|
+ - Improvement + Critical = 2 (High)
|
|
|
|
|
+ - Improvement + High = 1 (Normal)
|
|
|
|
|
+ - Improvement + Normal = 0 (Low)
|
|
|
|
|
+ """
|
|
|
|
|
+ if not self.request_type_id or not self.business_impact:
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ # Determine if it's an incident (code 'INC') or improvement
|
|
|
|
|
+ is_incident = self.request_type_id.code == 'INC'
|
|
|
|
|
+
|
|
|
|
|
+ # Priority mapping based on business_impact
|
|
|
|
|
+ # business_impact: '0' = Critical, '1' = High, '2' = Normal
|
|
|
|
|
+ # priority: '0' = Low, '1' = Normal, '2' = High, '3' = Urgent
|
|
|
|
|
+ priority_map = {
|
|
|
|
|
+ # Incidents get +1 priority boost
|
|
|
|
|
+ ('INC', '0'): '3', # Incident + Critical = Urgent
|
|
|
|
|
+ ('INC', '1'): '2', # Incident + High = High
|
|
|
|
|
+ ('INC', '2'): '1', # Incident + Normal = Normal
|
|
|
|
|
+ # Improvements have standard mapping
|
|
|
|
|
+ ('IMP', '0'): '2', # Improvement + Critical = High
|
|
|
|
|
+ ('IMP', '1'): '1', # Improvement + High = Normal
|
|
|
|
|
+ ('IMP', '2'): '0', # Improvement + Normal = Low
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ type_code = self.request_type_id.code or ''
|
|
|
|
|
+ key = (type_code, self.business_impact)
|
|
|
|
|
+
|
|
|
|
|
+ if key in priority_map:
|
|
|
|
|
+ self.priority = priority_map[key]
|
|
|
|
|
+
|