-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from calyx-servicios/upd-helpdesk-oca
[UPD][helpdesk_motive_web]
- Loading branch information
Showing
8 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import controllers | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
'name': 'Custom Helpdesk', | ||
'version': '1.0', | ||
'summary': 'Customize Helpdesk ticket creation', | ||
'description': 'This module customizes the Helpdesk ticket creation process.', | ||
'author': 'enzogonzalezdev', | ||
'category': 'Helpdesk', | ||
'depends': ['helpdesk_mgmt', 'helpdesk_motive'], | ||
'data': [ | ||
"views/helpdesk_ticket_motive.xml", | ||
"security/ir.model.access.csv"], | ||
'installable': True, | ||
'application': False, | ||
'license': 'LGPL-3', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import logging | ||
import base64 | ||
import werkzeug | ||
import odoo.http as http | ||
from odoo.http import request | ||
from odoo.tools import plaintext2html | ||
|
||
from odoo.addons.helpdesk_mgmt.controllers.main import HelpdeskTicketController | ||
#from odoo.addons.yourmodulename.controllers.yourpythonfilename import warehouse | ||
|
||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
class HelpdeskTicketControllerInherit(HelpdeskTicketController): | ||
|
||
def _prepare_submit_ticket_vals(self, **kw): | ||
res = super(HelpdeskTicketControllerInherit, self)._prepare_submit_ticket_vals(**kw) | ||
lista = ['team', 'category', 'subject', 'description', 'attachment'] | ||
for key,value in res.items(): | ||
if key in lista: | ||
continue | ||
|
||
res['description'] += f'{key}: {value}' | ||
kw.pop(key) | ||
return res | ||
|
||
@http.route("/new/ticket", type="http", auth="user", website=True) | ||
def create_new_ticket(self, **kw): | ||
session_info = http.request.env["ir.http"].session_info() | ||
company = request.env.company | ||
category_model = http.request.env["helpdesk.ticket.category"] | ||
categories = category_model.with_company(company.id).search( | ||
[("active", "=", True)] | ||
) | ||
email = http.request.env.user.email | ||
name = http.request.env.user.name | ||
company = request.env.company | ||
# Obtener line_ids | ||
line_ids = request.env['helpdesk.ticket.motive.line'].sudo().search([('team_id.show_in_portal', '=', True),('required_field', '=', True)]) | ||
|
||
return http.request.render( | ||
"helpdesk_mgmt.portal_create_ticket", | ||
{ | ||
"categories": categories, | ||
"teams": self._get_teams(), | ||
"email": email, | ||
"name": name, | ||
"ticket_team_id_required": ( | ||
company.helpdesk_mgmt_portal_team_id_required | ||
), | ||
"ticket_category_id_required": ( | ||
company.helpdesk_mgmt_portal_category_id_required | ||
), | ||
"max_upload_size": session_info["max_file_upload_size"], | ||
"line_ids": line_ids, # Pasar line_ids al template | ||
}, | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import helpdesk_ticket_motive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class HelpdeskMotive(models.Model): | ||
_inherit = "helpdesk.ticket.motive" | ||
|
||
line_ids = fields.One2many('helpdesk.ticket.motive.line', 'motive_id', string="Lines") | ||
|
||
|
||
class HepdeskMotiveLine(models.Model): | ||
_name = "helpdesk.ticket.motive.line" | ||
_description = "Helpdesk Motive Lines" | ||
|
||
description = fields.Char(string="Descripcion", store=True) | ||
required_field = fields.Boolean(string="Mostrar en portal", store=True) | ||
motive_id = fields.Many2one('helpdesk.ticket.motive', string="Motive", ondelete='cascade') | ||
team_id = fields.Many2one('helpdesk.ticket.team', related="motive_id.team_id", readonly=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
ir_model_access_helpdesk_motive_line_user,helpdesk_motive_line_group_user,model_helpdesk_ticket_motive_line,,1,1,1,1 | ||
ir_model_access_helpdesk_motive_line_manager,helpdesk_motive_line_group_manager,model_helpdesk_ticket_motive_line,,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- Copyright (C) 2019 Konos | ||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). --> | ||
<odoo> | ||
<record model="ir.ui.view" id="helpdesk_ticket_motive_form_inherit"> | ||
<field name="name">helpdesk.ticket.motive.form</field> | ||
<field name="inherit_id" ref="helpdesk_motive.helpdesk_ticket_motive_form"/> | ||
<field name="model">helpdesk.ticket.motive</field> | ||
<field name="arch" type="xml"> | ||
<field name="team_id" position="after"> | ||
<group> | ||
<field name="line_ids"> | ||
<tree editable="bottom"> | ||
<field name="description"/> | ||
<field name="required_field"/> | ||
</tree> | ||
</field> | ||
</group> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
<!-- Vista de árbol para el modelo secundario --> | ||
<record model="ir.ui.view" id="helpdesk_ticket_motive_line_tree_inherit"> | ||
<field name="name">helpdesk.ticket.motive.line.tree</field> | ||
<field name="model">helpdesk.ticket.motive.line</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="description"/> | ||
<field name="required_field"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="helpdesk_ticket_motive_tree"> | ||
<field name="name">helpdesk.ticket.motive.tree</field> | ||
<field name="model">helpdesk.ticket.motive</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="name" /> | ||
<field name="team_id" /> | ||
</tree> | ||
</field> | ||
</record> | ||
<record id="action_helpdesk_ticket_motive_tree" model="ir.actions.act_window"> | ||
<field name="name">Helpdesk Ticket Motive</field> | ||
<field name="res_model">helpdesk.ticket.motive</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
<menuitem | ||
id="helpdesk_motive" | ||
name="Motives" | ||
parent="helpdesk_mgmt.helpdesk_ticket_config_main_menu" | ||
action="action_helpdesk_ticket_motive_tree" | ||
sequence="7" | ||
/> | ||
</odoo> | ||
|