diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 17:14:58 +0700 |
| commit | 1ca3b3df3421961caec3b747a364071c80f5c7da (patch) | |
| tree | 6778a1f0f3f9b4c6e26d6d87ccde16e24da6c9d6 /sh_helpdesk/models/helpdesk_policies.py | |
| parent | b57188be371d36d96caac4b8d65a40745c0e972c (diff) | |
initial commit
Diffstat (limited to 'sh_helpdesk/models/helpdesk_policies.py')
| -rw-r--r-- | sh_helpdesk/models/helpdesk_policies.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sh_helpdesk/models/helpdesk_policies.py b/sh_helpdesk/models/helpdesk_policies.py new file mode 100644 index 0000000..6efa762 --- /dev/null +++ b/sh_helpdesk/models/helpdesk_policies.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Part of Softhealer Technologies. + +from odoo import models, fields + + +class HelpdeskSLAPolicies(models.Model): + _name = 'sh.helpdesk.sla' + _description = 'Helpdesk SLA Policies' + + def get_deafult_company(self): + company_id = self.env.company + return company_id + + name = fields.Char('Name',required=True) + sh_team_id = fields.Many2one('helpdesk.team','Helpdesk Team',required=True) + sh_ticket_type_id = fields.Many2one('helpdesk.ticket.type','Helpdesk Team Type') + sh_sla_target_type = fields.Selection([('reaching_stage','Reaching Stage'),('assign_to','Assigned To')],default='reaching_stage',string='SLA Target Type') + sh_stage_id = fields.Many2one('helpdesk.stages',string='Reach Stage') + sh_days = fields.Integer('Days',required=True) + sh_hours = fields.Integer('Hours',required=True) + sh_minutes = fields.Integer('Minutes',required=True) + company_id = fields.Many2one( + 'res.company', string="Company", default=get_deafult_company) + sla_ticket_count = fields.Integer(compute='_compute_helpdesk_ticket_sla') + + def _compute_helpdesk_ticket_sla(self): + for record in self: + record.sla_ticket_count = 0 + tickets = self.env['helpdesk.ticket'].search( + [('sh_sla_policy_ids', 'in', self.ids)], limit=None) + record.sla_ticket_count = len(tickets.ids) + + + def action_view_tickets(self): + self.ensure_one() + tickets = self.env['helpdesk.ticket'].sudo().search( + [('sh_sla_policy_ids', 'in', self.ids)]) + action = self.env["ir.actions.actions"]._for_xml_id( + "sh_helpdesk.helpdesk_ticket_action") + if len(tickets) > 1: + action['domain'] = [('id', 'in', tickets.ids)] + elif len(tickets) == 1: + form_view = [ + (self.env.ref('sh_helpdesk.helpdesk_ticket_form_view').id, 'form')] + if 'views' in action: + action['views'] = form_view + \ + [(state, view) + for state, view in action['views'] if view != 'form'] + else: + action['views'] = form_view + action['res_id'] = tickets.id + else: + action = {'type': 'ir.actions.act_window_close'} + return action
\ No newline at end of file |
