diff --git a/helpdesk_close_tickets/__init__.py b/helpdesk_close_tickets/__init__.py new file mode 100644 index 0000000..dc62463 --- /dev/null +++ b/helpdesk_close_tickets/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Jarsa Sistemas, S.A. de C.V. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/helpdesk_close_tickets/__manifest__.py b/helpdesk_close_tickets/__manifest__.py new file mode 100644 index 0000000..6093cda --- /dev/null +++ b/helpdesk_close_tickets/__manifest__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# © 2016 Jarsa Sistemas, S.A. de C.V. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Close Tickets", + "summary": "Close Tickets", + "version": "10.0.1.0.0", + "category": "Hidden", + "website": "https://www.jarsa.com.mx/", + "author": "JARSA Sistemas, S.A. de C.V.", + "license": "AGPL-3", + "installable": True, + "depends": [ + 'helpdesk', + ], + "data": [ + 'data/template.xml', + 'data/ir_cron.xml', + 'data/ir_action_server.xml', + 'data/config_parameter_data.xml', + 'data/ir_filters.xml', + 'data/base_action_rule.xml', + ], + "demo": [ + ] +} diff --git a/helpdesk_close_tickets/data/base_action_rule.xml b/helpdesk_close_tickets/data/base_action_rule.xml new file mode 100644 index 0000000..1fc194e --- /dev/null +++ b/helpdesk_close_tickets/data/base_action_rule.xml @@ -0,0 +1,13 @@ + + + + Close ticket for time + on_write + + + [('stage_id', '=', 9)] + + [('stage_id', 'in', [3])] + + + diff --git a/helpdesk_close_tickets/data/config_parameter_data.xml b/helpdesk_close_tickets/data/config_parameter_data.xml new file mode 100644 index 0000000..3760196 --- /dev/null +++ b/helpdesk_close_tickets/data/config_parameter_data.xml @@ -0,0 +1,7 @@ + + + + helpdesk_auto_close + 5/9 + + \ No newline at end of file diff --git a/helpdesk_close_tickets/data/ir_action_server.xml b/helpdesk_close_tickets/data/ir_action_server.xml new file mode 100644 index 0000000..7cc2e65 --- /dev/null +++ b/helpdesk_close_tickets/data/ir_action_server.xml @@ -0,0 +1,39 @@ + + + + Close Ticket + + True + ir.actions.server + email + 99 + ${object.rating_get_rated_partner_id().email_formatted | safe} + ${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email else object.partner_email|safe)} + ${object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email and object.partner_id.id or False} + + ${object.display_name} + + + + + +
+ ${user.company_id.name} +
+ +
+

Dear ${object.partner_id.name or 'Madam, Sir'},

+

This automatic message informs you that we have determined your ticket (reference ${object.id}) because you have not received an answer on your part.

+

We hope that the services provided have fulfilled their expectations. If you have more questions or comments, please do not hesitate to reply to this email to re-open your ticket. Thank you for your cooperation.

+

Kind regards, ${object.team_id.name or 'Helpdesk'} Team.

+
+
+ ${user.signature | safe} +

+ Sent by ${user.company_id.name} using Odoo +

+
+ ]]>
+
+
\ No newline at end of file diff --git a/helpdesk_close_tickets/data/ir_cron.xml b/helpdesk_close_tickets/data/ir_cron.xml new file mode 100644 index 0000000..07af11a --- /dev/null +++ b/helpdesk_close_tickets/data/ir_cron.xml @@ -0,0 +1,15 @@ + + + + + Helpdesk Close Tickets Cron + + 1 + days + -1 + + + + + + diff --git a/helpdesk_close_tickets/data/ir_filters.xml b/helpdesk_close_tickets/data/ir_filters.xml new file mode 100644 index 0000000..06697f8 --- /dev/null +++ b/helpdesk_close_tickets/data/ir_filters.xml @@ -0,0 +1,19 @@ + + + + Stage for no close + helpdesk.ticket + [('stage_id', 'in', [3])] + + + {} + + + Stage close + helpdesk.ticket + [('stage_id', '=', 9)] + + + {} + + diff --git a/helpdesk_close_tickets/data/template.xml b/helpdesk_close_tickets/data/template.xml new file mode 100644 index 0000000..2190131 --- /dev/null +++ b/helpdesk_close_tickets/data/template.xml @@ -0,0 +1,37 @@ + + + + Close Tickets + ${object.rating_get_rated_partner_id().email_formatted | safe} + ${object.display_name} + ${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email else object.partner_email|safe)} + ${object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email and object.partner_id.id or False} + + + + + + + +
+ ${user.company_id.name} +
+ +
+

Dear ${object.partner_id.name or 'Madam, Sir'},

+

This automatic message informs you that we have determined your ticket (reference ${object.id}) because you have not received an answer on your part.

+

We hope that the services provided have fulfilled their expectations. If you have more questions or comments, please do not hesitate to reply to this email to re-open your ticket. Thank you for your cooperation.

+

Kind regards, ${object.team_id.name or 'Helpdesk'} Team.

+
+
+ ${user.signature | safe} +

+ Sent by ${user.company_id.name} using Odoo +

+
+ ]]> +
+
+
+ diff --git a/helpdesk_close_tickets/models/__init__.py b/helpdesk_close_tickets/models/__init__.py new file mode 100644 index 0000000..d2930a3 --- /dev/null +++ b/helpdesk_close_tickets/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016, Jarsa Sistemas, S.A. de C.V. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import helpdesk_ticket diff --git a/helpdesk_close_tickets/models/helpdesk_ticket.py b/helpdesk_close_tickets/models/helpdesk_ticket.py new file mode 100644 index 0000000..7339bd3 --- /dev/null +++ b/helpdesk_close_tickets/models/helpdesk_ticket.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2016, Jarsa Sistemas, S.A. de C.V. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class HelpdeskTicket(models.Model): + _inherit = 'helpdesk.ticket' + + @api.model + def close_tickets(self): + parameter = self.env['ir.config_parameter'].get_param( + 'helpdesk_auto_close', False) + if parameter: + value = parameter.split('/') + tickets_authorized = self.search([('stage_id', '=', int(value[1]))]) + stage_close = self.env['helpdesk.stage'].search([ + ('is_close', '=', True)], order='sequence', limit=1).id + for ticket in tickets_authorized: + times = [fields.Datetime.from_string(x) + for x in ticket.message_ids.mapped('date')] + date_end = times[0] + date_now = fields.Datetime.from_string(fields.Datetime.now()) + direfencia = date_now - date_end + if direfencia.days >= int(value[0]): + ticket.stage_id = stage_close diff --git a/helpdesk_merge_tickets/wizards/wizard_merge.py b/helpdesk_merge_tickets/wizards/wizard_merge.py index 1b09f96..20e04e7 100644 --- a/helpdesk_merge_tickets/wizards/wizard_merge.py +++ b/helpdesk_merge_tickets/wizards/wizard_merge.py @@ -43,23 +43,15 @@ def merge(self): attachments = self.env['ir.attachment'].search([ ('res_model', '=', 'helpdesk.ticket'), ('res_id', '=', line.id)]) - followers = self.env['mail.followers'].search([ - ('res_model', '=', 'helpdesk.ticket'), - ('res_id', '=', line.id)]) + attachments.write({ + 'res_id': main.id, + 'res_name': main.name, + }) + line.message_ids.write({ + 'res_id': main.id, + 'record_name': main.name, + }) + line.message_follower_ids.write({'res_id': main.id}) - for follower in followers: - if (follower.partner_id not in - main.message_follower_ids.mapped('partner_id')): - follower.write({'res_id': main.id}) - for attachment in attachments: - attachment.write({ - 'res_id': main.id, - 'res_name': main.name, - }) - for msg in line.message_ids: - msg.write({ - 'res_id': main.id, - 'record_name': main.name, - }) if line.id != main.id: line.unlink()