Commit cac10621 by Arturo Jasso Origel

se corrigieron las vistas dentro del portal, ya que ocasionaba un error al…

se corrigieron las vistas dentro del portal, ya que ocasionaba un error al momento de intentar ver un ticket, se agregó verificación en los radio button para evitar que estuvieran vacios, se realizo la misma verificación del contacto vacio
parent 0fee9a34
...@@ -124,15 +124,19 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -124,15 +124,19 @@ class PortalCustomerMaintenence(CustomerPortal):
'label': _('Status') 'label': _('Status')
}, },
'category': { 'maintenance_type': {
'input': 'category', 'input': 'maintenance_type',
'label': _('Category') 'label': _('Tipo de mantenimiento')
}, },
'priority': { 'severity_type': {
'input': 'priority', 'input': 'severity_type',
'label': _('Priority') 'label': _('Gravedad')
},
'state': {
'input': 'state',
'label': _('Reply Status')
}, },
} }
...@@ -263,87 +267,45 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -263,87 +267,45 @@ class PortalCustomerMaintenence(CustomerPortal):
maintenance_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_maintenance.maintenance').id)) maintenance_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_maintenance.maintenance').id))
# pager # pager
pager = portal_pager(url="/my/mantenimientos",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=maintenance_count,page=page,step=self._items_per_page) pager = portal_pager(url="/my/mantenimientos",url_args={'sortby': sortby,'search_in': search_in,'search': search,'filterby': filterby},total=maintenance_count,page=page,step=self._items_per_page)
if groupby == 'create_by':
order = "create_uid, %s" % order
elif groupby == 'ticket_type': if groupby == 'status':
order = "ticket_type, %s" % order
elif groupby == 'status':
order = "stage_id, %s" % order order = "stage_id, %s" % order
elif groupby == 'customer':
order = "partner_id, %s" % order
elif groupby == 'category':
order = "category_id, %s" % order
elif groupby == 'subcategory':
order = "sub_category_id, %s" % order
elif groupby == 'subject':
order = "subject_id, %s" % order
elif groupby == 'priority':
order = "priority, %s" % order
elif groupby == 'state': elif groupby == 'state':
order = 'state,%s' % order order = 'state,%s' % order
elif groupby == 'maintenance_type': elif groupby == 'maintenance_type':
order = "maintenance_type_id, %s" % order order = "maintenance_type_id, %s" % order
elif groupby == 'severity_type': elif groupby == 'severity_type':
order = "severity_type, %s" % order order = "severity_type, %s" % order
tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset']) tickets = HelpdeskTicket.search(domain,order=order,limit=self._items_per_page,offset=pager['offset'])
request.session['my_tickets_history'] = tickets.ids[:100] request.session['my_tickets_history'] = tickets.ids[:100]
if groupby == 'create_by':
grouped_tickets = [
HelpdeskTicket.concat(*g) if groupby == 'status':
for k, g in groupbyelem(tickets, itemgetter('create_uid'))
]
elif groupby == 'ticket_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('ticket_type'))
]
elif groupby == 'status':
grouped_tickets = [ grouped_tickets = [
HelpdeskTicket.concat(*g) HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('stage_id')) for k, g in groupbyelem(tickets, itemgetter('stage_id'))
] ]
elif groupby == 'customer':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('partner_id'))
]
elif groupby == 'category':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('category_id'))
]
elif groupby == 'subcategory':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('sub_category_id'))
]
elif groupby == 'subject':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('subject_id'))
]
elif groupby == 'priority':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('priority'))
]
elif groupby == 'state': elif groupby == 'state':
grouped_tickets = [ grouped_tickets = [
HelpdeskTicket.concat(*g) HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('state')) for k, g in groupbyelem(tickets, itemgetter('state'))
] ]
elif groupby == 'maintenance_type': elif groupby == 'maintenance_type':
grouped_tickets = [ grouped_tickets = [
HelpdeskTicket.concat(*g) HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('maintenance_type_id')) for k, g in groupbyelem(tickets, itemgetter('maintenance_type_id'))
] ]
elif groupby == 'severity_type': elif groupby == 'severity_type':
grouped_tickets = [ grouped_tickets = [
HelpdeskTicket.concat(*g) HelpdeskTicket.concat(*g)
...@@ -377,11 +339,13 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -377,11 +339,13 @@ class PortalCustomerMaintenence(CustomerPortal):
partner_id = False partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '': if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))]).filtered(lambda user: len(user.user_ids) > 0 )
else: else:
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1) [('email', '=', kw.get('portal_email'))]).filtered(lambda user: len(user.user_ids) > 0 )
if partner_id and len(partner_id) > 1:
partner_id = request.env.user.partner_id
if not partner_id: if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"}) return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"})
if partner_id: if partner_id:
...@@ -790,11 +754,13 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -790,11 +754,13 @@ class PortalCustomerMaintenence(CustomerPortal):
partner_id = False partner_id = False
if kw.get('partner_id') and kw.get('partner_id') != '': if kw.get('partner_id') and kw.get('partner_id') != '':
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('id', '=', int(kw.get('partner_id')))], limit=1) [('id', '=', int(kw.get('partner_id')))]).filtered(lambda user: len(user.user_ids) > 0 )
else: else:
partner_id = request.env['res.partner'].sudo().search( partner_id = request.env['res.partner'].sudo().search(
[('email', '=', kw.get('portal_email'))], limit=1) [('email', '=', kw.get('portal_email'))]).filtered(lambda user: len(user.user_ids) > 0 )
if partner_id and len(partner_id) > 1:
partner_id = request.env.user.partner_id
if not partner_id: if not partner_id:
return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"}) return json.dumps({"resp":"Error","message":"Colaborador no encontrado, favor de verificar que haya agregado uno"})
if partner_id: if partner_id:
...@@ -874,34 +840,4 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -874,34 +840,4 @@ class PortalCustomerMaintenence(CustomerPortal):
except Exception as e: except Exception as e:
_logger.exception('Something went wrong %s',str(e)) _logger.exception('Something went wrong %s',str(e))
"""@http.route(['/my/manteniminetos/emergencias/<int:ticket_id>'],type='http',auth="public",website=True)
def portal_my_ticket_detail_maintenance_emergency(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try:
ticket_sudo = self._document_check_access('helpdesk.ticket', ticket_id, access_token=access_token)
except (AccessError, MissingError):
return request.redirect('/my')
if report_type in ('html', 'pdf', 'text'):
return self._show_report(model=ticket_sudo,report_type=report_type,report_ref='sh_all_in_one_helpdesk.action_portal_report_helpdesk_ticket',download=download)
if ticket_sudo:
if request.env.company.sh_receive_email_seeing_ticket:
body = _('Ticket visto por el cliente %s',ticket_sudo.partner_id.name)
_message_post_helper(
"helpdesk.ticket",
ticket_sudo.id,
body,
token=ticket_sudo.access_token,
message_type="notification",
subtype_xmlid="mail.mt_note",
partner_ids=ticket_sudo.user_id.sudo().partner_id.ids,
)
values = {
'token': access_token,
'maintenance': ticket_sudo,
'message': message,
'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html',
}
return request.render("helpdesk_maintenance.portal_ticket_page_maintenance_emergency",values)"""
\ No newline at end of file
...@@ -7,7 +7,8 @@ $(document).ready(function(e) { ...@@ -7,7 +7,8 @@ $(document).ready(function(e) {
$("#portal_date_fail").datepicker({ dateFormat: 'dd-mm-yy' }); $("#portal_date_fail").datepicker({ dateFormat: 'dd-mm-yy' });
//verify_date(); verify_date();
$("#form_id").submit(function (e){ $("#form_id").submit(function (e){
var ticket_type = $("#tck_type").val(); var ticket_type = $("#tck_type").val();
if (ticket_type == "mantenimiento"){ if (ticket_type == "mantenimiento"){
...@@ -53,6 +54,7 @@ $(document).ready(function(e) { ...@@ -53,6 +54,7 @@ $(document).ready(function(e) {
} }
if (ticket_type == "emergencia_mantenimiento"){ if (ticket_type == "emergencia_mantenimiento"){
var req = required_maintenance_emergency() var req = required_maintenance_emergency()
console.log(req)
if(req['portal_contact_name'] == ""){ if(req['portal_contact_name'] == ""){
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Nombre"); show_error("Es necesario llenar el campo de Nombre");
...@@ -96,9 +98,9 @@ $(document).ready(function(e) { ...@@ -96,9 +98,9 @@ $(document).ready(function(e) {
'portal_phone': $("#portal_phone").val(), 'portal_phone': $("#portal_phone").val(),
'portal_main_type': $("#portal_main_type").val(), 'portal_main_type': $("#portal_main_type").val(),
'portal_date_fail':$("#portal_date_fail").val(), 'portal_date_fail':$("#portal_date_fail").val(),
'portal_severity': $("#portal_severity").is(':checked'), 'portal_severity': $('input[name="portal_severity"]:checked').is(':checked'),
'portal_description': $("#portal_description").val(), 'portal_description': $("#portal_description").val(),
'portal_fail_type': $("#portal_fail_type").is(':checked'), 'portal_fail_type': $('input[name="portal_fail_type"]:checked').is(':checked'),
'portal_file': document.getElementById('portal_file').files.length 'portal_file': document.getElementById('portal_file').files.length
} }
} }
...@@ -111,7 +113,7 @@ $(document).ready(function(e) { ...@@ -111,7 +113,7 @@ $(document).ready(function(e) {
'portal_phone': $("#portal_phone").val(), 'portal_phone': $("#portal_phone").val(),
'portal_date_fail': $("#portal_date_fail").val(), 'portal_date_fail': $("#portal_date_fail").val(),
'portal_description': $("#portal_description").val(), 'portal_description': $("#portal_description").val(),
'portal_fail_type': $("#portal_fail_type").is(':checked'), 'portal_fail_type': $('input[name="portal_fail_type"]:checked').is(':checked'),
'portal_file': document.getElementById('portal_file').files.length 'portal_file': document.getElementById('portal_file').files.length
} }
} }
...@@ -125,7 +127,7 @@ $(document).ready(function(e) { ...@@ -125,7 +127,7 @@ $(document).ready(function(e) {
}) })
} }
/*function verify_date(){ function verify_date(){
var t_type = $("#tck_type").val(); var t_type = $("#tck_type").val();
if (t_type == "mantenimiento"){ if (t_type == "mantenimiento"){
console.log("mantenimiento"); console.log("mantenimiento");
...@@ -136,7 +138,6 @@ $(document).ready(function(e) { ...@@ -136,7 +138,6 @@ $(document).ready(function(e) {
hours == date.getHours(); hours == date.getHours();
if(hours >= 8 && hours <= 20){ if(hours >= 8 && hours <= 20){
$("#mdl_shw").val("show"); $("#mdl_shw").val("show");
//$("#new_request").addClass("");
}else{ }else{
$("#mdl_shw").val("hide"); $("#mdl_shw").val("hide");
$("#new_request").addClass("d-none") $("#new_request").addClass("d-none")
...@@ -146,7 +147,7 @@ $(document).ready(function(e) { ...@@ -146,7 +147,7 @@ $(document).ready(function(e) {
$("#new_request").addClass("d-none") $("#new_request").addClass("d-none")
} }
} }
}*/ }
if($("#mdl_shw").val() == 'show'){ if($("#mdl_shw").val() == 'show'){
$("#createticketModalMaintenance").modal("show"); $("#createticketModalMaintenance").modal("show");
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<!--Tipo de mantenimiento--> <!--Tipo de mantenimiento-->
<div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_main_type' in error and 'has-error' or ''}"> <div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_main_type' in error and 'has-error' or ''}">
<label class="control-label" for="portal_main_type">Tipo de Mantenimiento:</label> <label class="control-label" for="portal_main_type">Tipo de Mantenimiento:</label>
<select class="form-control form-field o_website_form_required_custom" id="portal_main_type" name="portal_main_type"> <select class="form-control form-field o_website_form_required_custom" id="portal_main_type" name="portal_main_type" required="">
<option></option> <option></option>
<t t-foreach="request.env['maintenance.type'].sudo().search([])" t-as="type"> <t t-foreach="request.env['maintenance.type'].sudo().search([])" t-as="type">
<option t-att-value="type.id"><t t-esc="type.name" /></option> <option t-att-value="type.id"><t t-esc="type.name" /></option>
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<t t-if="not tickets"> <t t-if="not tickets">
<p>No hay tickets relacionados.</p> <p>No hay tickets relacionados.</p>
</t> </t>
<t t-if="grouped_tickets" t-call="portal.portal_table"> <t t-if="grouped_tickets" t-call="portal.portal_table">
<t t-foreach="grouped_tickets" t-as="ticket"> <t t-foreach="grouped_tickets" t-as="ticket">
<thead> <thead>
...@@ -244,8 +244,6 @@ ...@@ -244,8 +244,6 @@
<template id="helpdesk_ticket_portal_content_maintenance" name="Helpdesk Ticket Portal Content"> <template id="helpdesk_ticket_portal_content_maintenance" name="Helpdesk Ticket Portal Content">
<!-- Intro -->
<div id="introduction" t-attf-class="pb-2 pt-3 #{'card-header bg-white' if report_type == 'html' else ''}"> <div id="introduction" t-attf-class="pb-2 pt-3 #{'card-header bg-white' if report_type == 'html' else ''}">
<h2 class="my-0"> <h2 class="my-0">
<strong><em t-esc="maintenance.name" /></strong> <strong><em t-esc="maintenance.name" /></strong>
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
<odoo> <odoo>
<template id="portal_home_maintenance" name="Portal My Home : IT" inherit_id="portal.portal_my_home" priority="101"> <template id="portal_home_maintenance" name="Portal My Home : IT" inherit_id="portal.portal_my_home" priority="101">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside"> <xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry"> <t t-if="request.env.user.is_maintenance">
<t t-set="title">Mantenimiento</t> <t t-call="portal.portal_docs_entry">
<t t-set="url" t-value="'/my/mantenimiento'" /> <t t-set="title">Mantenimiento</t>
<t t-set="background" t-value="'/helpdesk_maintenance/static/src/img/mantenimiento.svg'"/> <t t-set="url" t-value="'/my/mantenimiento'" />
<t t-set="background" t-value="'/helpdesk_maintenance/static/src/img/mantenimiento.svg'"/>
</t>
</t> </t>
</xpath> </xpath>
</template> </template>
...@@ -23,11 +25,11 @@ ...@@ -23,11 +25,11 @@
</li> </li>
<li t-if="page_name == 'm_emergency' or m_emergency" t-attf-class="breadcrumb-item #{'active ' if not soporte else ''}"> <li t-if="page_name == 'm_emergency' or m_emergency" t-attf-class="breadcrumb-item #{'active ' if not soporte else ''}">
<a t-if="m_emergency" t-attf-href="/my/mantienimiento/emergencia?{{ keep_query() }}">Emergencia</a> <a t-if="m_emergency" t-attf-href="/my/mantenimientos?{{ keep_query() }}">Emergencia</a>
<t t-else="">Emergencia</t> <t t-else="">Emergencia</t>
</li> </li>
<li t-if="m_emergency" class="breadcrumb-item active"> <li t-if="m_emergency" class="breadcrumb-item active">
<t t-esc="maintenance.name" t-if="maintenance.name" /> <t t-esc="m_emergency.name" t-if="m_emergency.name" />
<t t-else=""><em>Mantenimiento</em></t> <t t-else=""><em>Mantenimiento</em></t>
</li> </li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment