From dd8f0ac268e8208342799a97fc70657276bcead0 Mon Sep 17 00:00:00 2001 From: SaraiOsorio Date: Wed, 29 Nov 2017 12:58:05 -0600 Subject: [PATCH 1/4] [add][helpdesk_close_tickets] --- helpdesk_close_tickets/__init__.py | 5 ++++ helpdesk_close_tickets/__manifest__.py | 26 ++++++++++++++++++ .../data/base_action_rule.xml | 13 +++++++++ .../data/config_parameter_data.xml | 7 +++++ .../data/ir_action_server.xml | 23 ++++++++++++++++ helpdesk_close_tickets/data/ir_cron.xml | 15 +++++++++++ helpdesk_close_tickets/data/ir_filters.xml | 11 ++++++++ helpdesk_close_tickets/models/__init__.py | 5 ++++ .../models/helpdesk_ticket.py | 27 +++++++++++++++++++ 9 files changed, 132 insertions(+) create mode 100644 helpdesk_close_tickets/__init__.py create mode 100644 helpdesk_close_tickets/__manifest__.py create mode 100644 helpdesk_close_tickets/data/base_action_rule.xml create mode 100644 helpdesk_close_tickets/data/config_parameter_data.xml create mode 100644 helpdesk_close_tickets/data/ir_action_server.xml create mode 100644 helpdesk_close_tickets/data/ir_cron.xml create mode 100644 helpdesk_close_tickets/data/ir_filters.xml create mode 100644 helpdesk_close_tickets/models/__init__.py create mode 100644 helpdesk_close_tickets/models/helpdesk_ticket.py 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..90cc87e --- /dev/null +++ b/helpdesk_close_tickets/__manifest__.py @@ -0,0 +1,26 @@ +# -*- 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/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..5e4641a --- /dev/null +++ b/helpdesk_close_tickets/data/base_action_rule.xml @@ -0,0 +1,13 @@ + + + + Close ticket for time + on_time + + + 5 + day + + + + 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..e34ed43 --- /dev/null +++ b/helpdesk_close_tickets/data/ir_action_server.xml @@ -0,0 +1,23 @@ + + + + Close Ticket + + True + ir.actions.server + email + 99 + + + Close Ticket + + True + ir.actions.server + code + + stage_solved = env['helpdesk.stage'].search([('is_close', '=', True)], order='sequence', limit=1).id + for record in records: + record.stage_id = stage_solved + + + \ 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..7f6fa96 --- /dev/null +++ b/helpdesk_close_tickets/data/ir_filters.xml @@ -0,0 +1,11 @@ + + + + Stage for no close + helpdesk.ticket + [('stage_id', 'in', [9])] + + + {} + + 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 From a2b1a87451cc1883ac23b56e514d3dbc598735eb Mon Sep 17 00:00:00 2001 From: SaraiOsorio Date: Mon, 4 Dec 2017 18:57:28 -0600 Subject: [PATCH 2/4] [REF][helpdesk_close_tickets]- send email --- helpdesk_close_tickets/__manifest__.py | 1 + .../data/base_action_rule.xml | 10 +++++----- .../data/ir_action_server.xml | 20 ++++++++----------- helpdesk_close_tickets/data/ir_filters.xml | 10 +++++++++- helpdesk_close_tickets/data/template.xml | 15 ++++++++++++++ 5 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 helpdesk_close_tickets/data/template.xml diff --git a/helpdesk_close_tickets/__manifest__.py b/helpdesk_close_tickets/__manifest__.py index 90cc87e..6093cda 100644 --- a/helpdesk_close_tickets/__manifest__.py +++ b/helpdesk_close_tickets/__manifest__.py @@ -15,6 +15,7 @@ 'helpdesk', ], "data": [ + 'data/template.xml', 'data/ir_cron.xml', 'data/ir_action_server.xml', 'data/config_parameter_data.xml', diff --git a/helpdesk_close_tickets/data/base_action_rule.xml b/helpdesk_close_tickets/data/base_action_rule.xml index 5e4641a..1fc194e 100644 --- a/helpdesk_close_tickets/data/base_action_rule.xml +++ b/helpdesk_close_tickets/data/base_action_rule.xml @@ -2,12 +2,12 @@ Close ticket for time - on_time + on_write + + [('stage_id', '=', 9)] - 5 - day - - + [('stage_id', 'in', [3])] + diff --git a/helpdesk_close_tickets/data/ir_action_server.xml b/helpdesk_close_tickets/data/ir_action_server.xml index e34ed43..2a461a1 100644 --- a/helpdesk_close_tickets/data/ir_action_server.xml +++ b/helpdesk_close_tickets/data/ir_action_server.xml @@ -7,17 +7,13 @@ ir.actions.server email 99 - - - Close Ticket - - True - ir.actions.server - code - - stage_solved = env['helpdesk.stage'].search([('is_close', '=', True)], order='sequence', limit=1).id - for record in records: - record.stage_id = stage_solved - + ${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} + \ No newline at end of file diff --git a/helpdesk_close_tickets/data/ir_filters.xml b/helpdesk_close_tickets/data/ir_filters.xml index 7f6fa96..06697f8 100644 --- a/helpdesk_close_tickets/data/ir_filters.xml +++ b/helpdesk_close_tickets/data/ir_filters.xml @@ -3,7 +3,15 @@ Stage for no close helpdesk.ticket - [('stage_id', 'in', [9])] + [('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..4c877b9 --- /dev/null +++ b/helpdesk_close_tickets/data/template.xml @@ -0,0 +1,15 @@ + + + + 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} + + + + + \ No newline at end of file From b90c047f51191df9843697337899b6007b28a69d Mon Sep 17 00:00:00 2001 From: SaraiOsorio Date: Tue, 5 Dec 2017 11:15:30 -0600 Subject: [PATCH 3/4] [REF][helpdesk_close_tickets] --- .../data/ir_action_server.xml | 26 ++++++++++++++-- helpdesk_close_tickets/data/template.xml | 30 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/helpdesk_close_tickets/data/ir_action_server.xml b/helpdesk_close_tickets/data/ir_action_server.xml index 2a461a1..7cc2e65 100644 --- a/helpdesk_close_tickets/data/ir_action_server.xml +++ b/helpdesk_close_tickets/data/ir_action_server.xml @@ -12,8 +12,28 @@ ${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/template.xml b/helpdesk_close_tickets/data/template.xml index 4c877b9..2190131 100644 --- a/helpdesk_close_tickets/data/template.xml +++ b/helpdesk_close_tickets/data/template.xml @@ -8,8 +8,30 @@ ${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 +

+
+ ]]> +
- \ No newline at end of file + + From 3800f1d3a19b8767a1d9317fbb1033e533e9e676 Mon Sep 17 00:00:00 2001 From: SaraiOsorio Date: Thu, 1 Feb 2018 16:25:59 -0600 Subject: [PATCH 4/4] [ref][helpdesk_merge_tickets]- add followers --- .../wizards/wizard_merge.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/helpdesk_merge_tickets/wizards/wizard_merge.py b/helpdesk_merge_tickets/wizards/wizard_merge.py index 6785f10..698101c 100644 --- a/helpdesk_merge_tickets/wizards/wizard_merge.py +++ b/helpdesk_merge_tickets/wizards/wizard_merge.py @@ -43,15 +43,14 @@ def merge(self): attachments = self.env['ir.attachment'].search([ ('res_model', '=', 'helpdesk.ticket'), ('res_id', '=', line.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, - }) + 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}) if line.id != main.id: line.unlink()