Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.0 so helpdesk #83

Open
wants to merge 5 commits into
base: 10.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions helpdesk_close_tickets/__init__.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions helpdesk_close_tickets/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [
]
}
13 changes: 13 additions & 0 deletions helpdesk_close_tickets/data/base_action_rule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="close_ticket_for_time" model="base.action.rule">
<field name="name">Close ticket for time</field>
<field name="kind">on_write</field>
<field name="model_id" ref="helpdesk_close_tickets.model_helpdesk_ticket"/>
<field name="filter_pre_id" ref="helpdesk_close_tickets.filter_tickets_touch"></field>
<field name="filter_pre_domain">[('stage_id', '=', 9)]</field>
<field name="filter_id" ref="helpdesk_close_tickets.filter_close"></field>
<field name="filter_domain">[('stage_id', 'in', [3])]</field>
<field name="server_action_ids" eval="[(6, 0, [ref('helpdesk_close_tickets.action_email_close_ticket')])]"/>
</record>
</odoo>
7 changes: 7 additions & 0 deletions helpdesk_close_tickets/data/config_parameter_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate='1'>
<record id="helpdesk_auto_close_parameter" model="ir.config_parameter">
<field name="key">helpdesk_auto_close</field>
<field name="value">5/9</field>
</record>
</odoo>
39 changes: 39 additions & 0 deletions helpdesk_close_tickets/data/ir_action_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<odoo>
<record id="action_email_close_ticket" model="ir.actions.server">
<field name="name">Close Ticket</field>
<field name="model_id" ref="helpdesk_close_tickets.model_helpdesk_ticket"/>
<field name="condition">True</field>
<field name="type">ir.actions.server</field>
<field name="state">email</field>
<field name="sequence">99</field>
<field name="email_from">${object.rating_get_rated_partner_id().email_formatted | safe}</field>
<field name="email_to">${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email else object.partner_email|safe)}</field>
<field name="partner_to">${object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email and object.partner_id.id or False}</field>
<field name="template_id" ref="email_template_close_tickets"/>
<field name="subject">${object.display_name}</field>
<field name="body_html"><![CDATA[
<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">
<table cellspacing="0" cellpadding="0" style="width:600px;border-collapse:collapse;background:inherit;color:inherit">
<tbody><tr>
<td valign="center" width="200" style="padding:10px 10px 10px 5px;font-size: 12px">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}">
</td>
</tr></tbody>
</table>
</div>
<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">
<p>Dear ${object.partner_id.name or 'Madam, Sir'},</p>
<p>This automatic message informs you that we have determined your ticket (reference ${object.id}) because you have not received an answer on your part.</p>
<p>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.</p>
<p>Kind regards, ${object.team_id.name or 'Helpdesk'} Team.</p>
</div>
<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">
${user.signature | safe}
<p style="font-size: 11px; margin-top: 10px;">
<strong>Sent by ${user.company_id.name} using <a href="www.odoo.com" style="text-decoration:none; color: #875A7B;">Odoo</a></strong>
</p>
</div>
]]></field>
</record>
</odoo>
15 changes: 15 additions & 0 deletions helpdesk_close_tickets/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="ir_cron_scheduler_invoice_email" model="ir.cron">
<field name="name">Helpdesk Close Tickets Cron</field>
<field name="user_id" ref="base.user_root"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'helpdesk.ticket'" name="model"/>
<field eval="'close_tickets'" name="function"/>
</record>
</data>
</odoo>
19 changes: 19 additions & 0 deletions helpdesk_close_tickets/data/ir_filters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="filter_close" model="ir.filters">
<field name="name">Stage for no close</field>
<field name="model_id">helpdesk.ticket</field>
<field name="domain">[('stage_id', 'in', [3])]</field>
<field eval="False" name="user_id"/>
<field name="is_default" eval="True"/>
<field name="context">{}</field>
</record>
<record id="filter_tickets_touch" model="ir.filters">
<field name="name">Stage close</field>
<field name="model_id">helpdesk.ticket</field>
<field name="domain">[('stage_id', '=', 9)]</field>
<field eval="False" name="user_id"/>
<field name="is_default" eval="True"/>
<field name="context">{}</field>
</record>
</odoo>
37 changes: 37 additions & 0 deletions helpdesk_close_tickets/data/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<odoo>
<record id="email_template_close_tickets" model="mail.template">
<field name="name">Close Tickets</field>
<field name="email_from">${object.rating_get_rated_partner_id().email_formatted | safe}</field>
<field name="subject">${object.display_name}</field>
<field name="email_to">${('' if object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email else object.partner_email|safe)}</field>
<field name="partner_to">${object.partner_id and object.partner_id.email and object.partner_id.email==object.partner_email and object.partner_id.id or False}</field>
<field name="model_id" ref="helpdesk_close_tickets.model_helpdesk_ticket"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">
<table cellspacing="0" cellpadding="0" style="width:600px;border-collapse:collapse;background:inherit;color:inherit">
<tbody><tr>
<td valign="center" width="200" style="padding:10px 10px 10px 5px;font-size: 12px">
<img src="/logo.png" style="padding: 0px; margin: 0px; height: auto; width: 80px;" alt="${user.company_id.name}">
</td>
</tr></tbody>
</table>
</div>
<div style="padding:0px;width:600px;margin:auto;background: #FFFFFF repeat top /100%;color:#777777">
<p>Dear ${object.partner_id.name or 'Madam, Sir'},</p>
<p>This automatic message informs you that we have determined your ticket (reference ${object.id}) because you have not received an answer on your part.</p>
<p>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.</p>
<p>Kind regards, ${object.team_id.name or 'Helpdesk'} Team.</p>
</div>
<div style="padding:0px;width:600px;margin:auto; margin-top: 10px; background: #fff repeat top /100%;color:#777777">
${user.signature | safe}
<p style="font-size: 11px; margin-top: 10px;">
<strong>Sent by ${user.company_id.name} using <a href="www.odoo.com" style="text-decoration:none; color: #875A7B;">Odoo</a></strong>
</p>
</div>
]]>
</field>
</record>
</odoo>

5 changes: 5 additions & 0 deletions helpdesk_close_tickets/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions helpdesk_close_tickets/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 9 additions & 17 deletions helpdesk_merge_tickets/wizards/wizard_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()