Commit 3f72f378 by Arturo Jasso Origel

restableciendo cambios de other_odoo_login

parent 5d9ba670
...@@ -97,7 +97,7 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -97,7 +97,7 @@ class PortalCustomerMaintenence(CustomerPortal):
@http.route(['/my/mantenimientos', '/my/mantenimientos/page/<int:page>'],type='http',auth="user",website=True) @http.route(['/my/mantenimientos', '/my/mantenimientos/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_maintenance(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw): def portal_my_maintenance(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='status',**kw):
values = self._prepare_portal_layout_values() values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo() HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
searchbar_sortings = { searchbar_sortings = {
...@@ -118,42 +118,23 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -118,42 +118,23 @@ class PortalCustomerMaintenence(CustomerPortal):
} }
searchbar_groupby = { searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': { 'status': {
'input': 'status', 'input': 'status',
'label': _('Status') 'label': _('Status')
}, },
'customer': {
'input': 'customer',
'label': _('Customer')
},
'category': { 'category': {
'input': 'category', 'input': 'category',
'label': _('Category') 'label': _('Category')
}, },
'subcategory': {
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': { 'priority': {
'input': 'priority', 'input': 'priority',
'label': _('Priority') 'label': _('Priority')
}, },
'state': {
'input': 'state',
'label': _('Reply Status')
},
} }
today = fields.Date.today() today = fields.Date.today()
...@@ -283,6 +264,9 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -283,6 +264,9 @@ 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': if groupby == 'create_by':
...@@ -303,6 +287,10 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -303,6 +287,10 @@ class PortalCustomerMaintenence(CustomerPortal):
order = "priority, %s" % order order = "priority, %s" % order
elif groupby == 'state': elif groupby == 'state':
order = 'state,%s' % order order = 'state,%s' % order
elif groupby == 'maintenance_type':
order = "maintenance_type_id, %s" % order
elif groupby == 'severity_type':
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]
...@@ -351,6 +339,16 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -351,6 +339,16 @@ class PortalCustomerMaintenence(CustomerPortal):
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':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('maintenance_type_id'))
]
elif groupby == 'severity_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('severity_type'))
]
# content according to pager and archive selected # content according to pager and archive selected
values.update({ values.update({
'created': ctr, 'created': ctr,
...@@ -442,7 +440,7 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -442,7 +440,7 @@ class PortalCustomerMaintenence(CustomerPortal):
if kw.get('portal_date_fail'): if kw.get('portal_date_fail'):
ticket_dic.update({ ticket_dic.update({
'date_fail': datetime.strptime(kw.get('portal_date_fail'),FORMAT).date(), 'date_fail': datetime.strptime(kw.get('portal_date_fail'),"%d-%m-%Y").date(),
}) })
if kw.get('portal_fail_type'): if kw.get('portal_fail_type'):
...@@ -502,11 +500,22 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -502,11 +500,22 @@ class PortalCustomerMaintenence(CustomerPortal):
'partner_id': ticket_sudo.partner_id.id, 'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html', 'report_type': 'html',
} }
if ticket_sudo.maintenance_type_id.id == request.env.ref('helpdesk_maintenance.emergency').id and ticket_sudo.severity_type == '3':
values = {
'token': access_token,
'm_emergency': 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)
return request.render("helpdesk_maintenance.portal_ticket_page_maintenance",values) return request.render("helpdesk_maintenance.portal_ticket_page_maintenance",values)
#apartado de emergencia #apartado de emergencia
@http.route(['/my/mantenimientos/emergencias', '/my/mantenimientos/emergencias/page/<int:page>'],type='http',auth="user",website=True) @http.route(['/my/mantenimientos/emergencias', '/my/mantenimientos/emergencias/page/<int:page>'],type='http',auth="user",website=True)
def portal_my_maintenance_emergency(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='create_by',**kw): def portal_my_maintenance_emergency(self,ctr='show',page=1,sortby=None,filterby=None,search=None,search_in='all',groupby='status',**kw):
values = self._prepare_portal_layout_values() values = self._prepare_portal_layout_values()
HelpdeskTicket = request.env['helpdesk.ticket'].sudo() HelpdeskTicket = request.env['helpdesk.ticket'].sudo()
searchbar_sortings = { searchbar_sortings = {
...@@ -527,42 +536,23 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -527,42 +536,23 @@ class PortalCustomerMaintenence(CustomerPortal):
} }
searchbar_groupby = { searchbar_groupby = {
'create_by': {
'input': 'create_by',
'label': _('Created By')
},
'ticket_type': {
'input': 'ticket_type',
'label': _('Ticket Type')
},
'status': { 'status': {
'input': 'status', 'input': 'status',
'label': _('Status') 'label': _('Status')
}, },
'customer': {
'input': 'customer', 'maintenance_type': {
'label': _('Customer') 'input': 'maintenance_type',
'label': _('Tipo de mantenimiento')
}, },
'category': {
'input': 'category',
'label': _('Category') 'severity_type': {
}, 'input': 'severity_type',
'subcategory': { 'label': _('Gravedad')
'input': 'subcategory',
'label': _('Sub Category')
},
'subject': {
'input': 'subject',
'label': _('Subject')
},
'priority': {
'input': 'priority',
'label': _('Priority')
},
'state': {
'input': 'state',
'label': _('Reply Status')
}, },
} }
today = fields.Date.today() today = fields.Date.today()
...@@ -687,11 +677,8 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -687,11 +677,8 @@ class PortalCustomerMaintenence(CustomerPortal):
domain = AND([domain, ticket_domain]) domain = AND([domain, ticket_domain])
maintenance_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_maintenance.maintenance').id and h.maintenance_type_id.id == request.env.ref('helpdesk_maintenance.emergency').id))
maintenance_count = len(HelpdeskTicket.search(domain).filtered(lambda h: h.team_id.id == request.env.ref('helpdesk_maintenance.maintenance').id and h.maintenance_type_id.id == request.env.ref('helpdesk_maintenance.emergency'.id)))
# pager # pager
pager = portal_pager(url="/my/mantenimientos/emergencias",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/emergencias",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': if groupby == 'create_by':
...@@ -712,6 +699,11 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -712,6 +699,11 @@ class PortalCustomerMaintenence(CustomerPortal):
order = "priority, %s" % order order = "priority, %s" % order
elif groupby == 'state': elif groupby == 'state':
order = 'state,%s' % order order = 'state,%s' % order
elif groupby == 'maintenance_type':
order = "maintenance_type_id, %s" % order
elif groupby == 'severity_type':
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]
...@@ -760,6 +752,16 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -760,6 +752,16 @@ class PortalCustomerMaintenence(CustomerPortal):
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':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('maintenance_type_id'))
]
elif groupby == 'severity_type':
grouped_tickets = [
HelpdeskTicket.concat(*g)
for k, g in groupbyelem(tickets, itemgetter('severity_type'))
]
# content according to pager and archive selected # content according to pager and archive selected
values.update({ values.update({
'created': ctr, 'created': ctr,
...@@ -796,13 +798,7 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -796,13 +798,7 @@ class PortalCustomerMaintenence(CustomerPortal):
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:
unvalued_tickets = len(
request.env['helpdesk.ticket'].sudo().search([
('stage_id','=',request.env.ref('sh_all_in_one_helpdesk.done_stage').id),
('priority_new','=',False)])
)
if unvalued_tickets >= 3:
return json.dumps({"resp":"Error","message":"Tienes demasiados tickets sin evaluar, favor de evaluarlos"})
ticket_dic = { ticket_dic = {
'partner_id': partner_id.id, 'partner_id': partner_id.id,
'ticket_from_portal': True 'ticket_from_portal': True
...@@ -825,7 +821,6 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -825,7 +821,6 @@ class PortalCustomerMaintenence(CustomerPortal):
'email': kw.get('portal_email'), 'email': kw.get('portal_email'),
}) })
team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_maintenance.maintenance').id) team_id = request.env['helpdesk.team'].sudo().browse(request.env.ref('helpdesk_maintenance.maintenance').id)
if team_id: if team_id:
ticket_dic.update({ ticket_dic.update({
...@@ -845,8 +840,9 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -845,8 +840,9 @@ class PortalCustomerMaintenence(CustomerPortal):
}) })
if kw.get('portal_date_fail'): if kw.get('portal_date_fail'):
ticket_dic.update({ ticket_dic.update({
'date_fail': datetime.strptime(kw.get('portal_date_fail'),FORMAT).date(), 'date_fail': datetime.strptime(kw.get('portal_date_fail'),"%d-%m-%Y").date(),
}) })
if kw.get('portal_fail_type'): if kw.get('portal_fail_type'):
...@@ -878,7 +874,7 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -878,7 +874,7 @@ 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) """@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): def portal_my_ticket_detail_maintenance_emergency(self,ticket_id,access_token=None,report_type=None,message=False,download=False,**kw):
try: try:
ticket_sudo = self._document_check_access('helpdesk.ticket', ticket_id, access_token=access_token) ticket_sudo = self._document_check_access('helpdesk.ticket', ticket_id, access_token=access_token)
...@@ -900,12 +896,12 @@ class PortalCustomerMaintenence(CustomerPortal): ...@@ -900,12 +896,12 @@ class PortalCustomerMaintenence(CustomerPortal):
) )
values = { values = {
'token': access_token, 'token': access_token,
'm_emergency': ticket_sudo, 'maintenance': ticket_sudo,
'message': message, 'message': message,
'bootstrap_formatting': True, 'bootstrap_formatting': True,
'partner_id': ticket_sudo.partner_id.id, 'partner_id': ticket_sudo.partner_id.id,
'report_type': 'html', 'report_type': 'html',
} }
return request.render("helpdesk_maintenance.portal_ticket_page_maintenance_emergency",values) return request.render("helpdesk_maintenance.portal_ticket_page_maintenance_emergency",values)"""
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data noupdate="1"> <data noupdate="0">
<record id="maintenance" model="helpdesk.team"> <record id="maintenance" model="helpdesk.team">
<field name="name">Mantenimiento</field> <field name="name">Mantenimiento</field>
<field name="short_name">MAN</field> <field name="short_name">MAN</field>
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
<field name="sh_resource_calendar_id" ref="resource.resource_calendar_std"/> <field name="sh_resource_calendar_id" ref="resource.resource_calendar_std"/>
<field name="is_maintenance_team" eval="True"/> <field name="is_maintenance_team" eval="True"/>
</record> </record>
<!--<record id="maintenance_emergency" model="helpdesk.team">
<field name="name">Mantenimiento Emergencias</field>
<field name="short_name">MAN911</field>
<field name="team_head" ref="base.user_admin"/>
<field name="sh_resource_calendar_id" ref="resource.resource_calendar_std"/>
<field name="is_maintenance_team" eval="True"/>
</record>-->
</data> </data>
</odoo> </odoo>
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<field name="name">Plomeria (baños y comedor)</field> <field name="name">Plomeria (baños y comedor)</field>
</record> </record>
<record id="emergency" model="maintenance.type"> <record id="emergency" model="maintenance.type">
<field name="name">Urgencia (comprometa la seguridad física o patrimonial</field> <field name="name">Urgencia (comprometa la seguridad física o patrimonial)</field>
</record> </record>
</data> </data>
......
...@@ -30,8 +30,6 @@ class HelpdeskTicket(models.Model): ...@@ -30,8 +30,6 @@ class HelpdeskTicket(models.Model):
for ticket in self: for ticket in self:
if ticket.team_id.id == self.env.ref('helpdesk_maintenance.maintenance').id: if ticket.team_id.id == self.env.ref('helpdesk_maintenance.maintenance').id:
ticket.access_url = '/my/manteniminetos/%s' % (ticket.id) ticket.access_url = '/my/manteniminetos/%s' % (ticket.id)
if ticket.team_id.id == self.env.ref('helpdesk_maintenance.maintenance').id and ticket.maintenance_type_id.id == self.env.ref('helpdesk_maintenance.emergency').id:
ticket.access_url = '/my/manteniminetos/emergencias/%s' % (ticket.id)
@api.depends('team_id') @api.depends('team_id')
def _verify_ticket_type(self): def _verify_ticket_type(self):
......
$(document).ready(function(e) { $(document).ready(function(e) {
$("#portal_date_fail").datepicker(); $("#new_request").click(function() {
$("#createticketModalMaintenance").modal("show");
});
$("#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"){
var req = required_maintenance() var req = required_maintenance()
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");
...@@ -26,7 +33,7 @@ $(document).ready(function(e) { ...@@ -26,7 +33,7 @@ $(document).ready(function(e) {
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Fecha de Falla"); show_error("Es necesario llenar el campo de Fecha de Falla");
} }
if(req['portal_severity'] == ""){ if(req['portal_severity'] == false){
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Tipo de Gravedad"); show_error("Es necesario llenar el campo de Tipo de Gravedad");
} }
...@@ -34,18 +41,18 @@ $(document).ready(function(e) { ...@@ -34,18 +41,18 @@ $(document).ready(function(e) {
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Descripción"); show_error("Es necesario llenar el campo de Descripción");
} }
if(req['portal_fail_type'] == ""){ if(req['portal_fail_type'] == false){
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Tipo de Falla"); show_error("Es necesario llenar el campo de Tipo de Falla");
} }
if(req['portal_file'] == 0){ if(req['portal_file'] == 0){
e.preventDefault(); e.preventDefault();
show_error("Es necesario agregar los archivos de evidencia|"); show_error("Es necesario agregar los archivos de evidencia");
} }
} }
if (ticket_type == "emergencia_mantenimiento"){ if (ticket_type == "emergencia_mantenimiento"){
var req = required_maintenance() var req = required_maintenance_emergency()
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");
...@@ -68,7 +75,7 @@ $(document).ready(function(e) { ...@@ -68,7 +75,7 @@ $(document).ready(function(e) {
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Descripción"); show_error("Es necesario llenar el campo de Descripción");
} }
if(req['portal_fail_type'] == ""){ if(req['portal_fail_type'] == false){
e.preventDefault(); e.preventDefault();
show_error("Es necesario llenar el campo de Tipo de Falla"); show_error("Es necesario llenar el campo de Tipo de Falla");
} }
...@@ -89,9 +96,9 @@ $(document).ready(function(e) { ...@@ -89,9 +96,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").val(), 'portal_severity': $("#portal_severity").is(':checked'),
'portal_description': $("#portal_description").val(), 'portal_description': $("#portal_description").val(),
'portal_fail_type': $("#portal_fail_type").val(), 'portal_fail_type': $("#portal_fail_type").is(':checked'),
'portal_file': document.getElementById('portal_file').files.length 'portal_file': document.getElementById('portal_file').files.length
} }
} }
...@@ -104,7 +111,7 @@ $(document).ready(function(e) { ...@@ -104,7 +111,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").val(), 'portal_fail_type': $("#portal_fail_type").is(':checked'),
'portal_file': document.getElementById('portal_file').files.length 'portal_file': document.getElementById('portal_file').files.length
} }
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<input type="hidden" name="mdl_shw" id="mdl_shw" t-att-value="created"/> <input type="hidden" name="mdl_shw" id="mdl_shw" t-att-value="created"/>
<div id="createticketModal" class="modal fade" role="dialog"> <div id="createticketModalMaintenance" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content" style="max-height:650px;"> <div class="modal-content" style="max-height:650px;">
<div class="modal-body"> <div class="modal-body">
...@@ -60,10 +60,12 @@ ...@@ -60,10 +60,12 @@
<input type="text" class="form-control form-field s_website_form_required" id="portal_phone" name="portal_phone" required="" /> <input type="text" class="form-control form-field s_website_form_required" id="portal_phone" name="portal_phone" required="" />
</div> </div>
<!--fecha de decteción de falla--> <!--fecha de decteción de falla-->
<div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_date_fail' in error and 'has-error' or ''}"> <div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_date_fail' in error and 'has-error' or ''}">
<label class="control-label" for="portal_date_fail">¿Cuando detecto la falla?</label> <label class="control-label" for="portal_date_fail">¿Cuando detecto la falla?</label>
<input type="text" class="form-control form-field s_website_form_required" id="portal_date_fail" name="portal_date_fail" placeholder="(dd/mm/yyyy)" required="" /> <input type="text" class="form-control form-field s_website_form_required" id="portal_date_fail" name="portal_date_fail" required="" />
</div> </div>
<!--Descripción detallada de falla--> <!--Descripción detallada de falla-->
...@@ -86,6 +88,7 @@ ...@@ -86,6 +88,7 @@
<span class="custom-file-control" /> <span class="custom-file-control" />
</label> </label>
</div> </div>
<div class="row mb-2"> <div class="row mb-2">
<div class="col-12 text-center border-top "> <div class="col-12 text-center border-top ">
<button type="submit" id="create_helpdesk_ticket" class="btn btn-primary mt-2 rounded">Crear Ticket</button> <button type="submit" id="create_helpdesk_ticket" class="btn btn-primary mt-2 rounded">Crear Ticket</button>
...@@ -131,9 +134,18 @@ ...@@ -131,9 +134,18 @@
<em class="font-weight-normal text-muted">Estatus de Respuesta:</em> <em class="font-weight-normal text-muted">Estatus de Respuesta:</em>
<span t-esc="ticket[0].state" /> <span t-esc="ticket[0].state" />
</th> </th>
<th t-if="groupby == 'maintenance_type'">
<em class="font-weight-normal text-muted">Tipo de mantenimiento:</em>
<span t-esc="ticket[0].maintenance_type_id.name" />
</th>
<th t-if="groupby == 'severity_type'">
<em class="font-weight-normal text-muted">Gravedad:</em>
<span t-esc="ticket[0].severity_type" />
</th>
<th>Fecha de creación</th> <th>Fecha de creación</th>
<th>Última actualización</th> <th>Tipo de mantenimiento</th>
<th>Tipo de Ticket</th> <th>Gravedad</th>
<th>Tipo de falla</th>
<th>Estado</th> <th>Estado</th>
</tr> </tr>
</thead> </thead>
...@@ -147,8 +159,9 @@ ...@@ -147,8 +159,9 @@
</a> </a>
</td> </td>
<td><span t-field="t.create_date" t-options='{"widget": "date"}' /></td> <td><span t-field="t.create_date" t-options='{"widget": "date"}' /></td>
<td><span t-field="t.write_date" t-options='{"widget": "date"}' /></td> <td><span t-field="t.maintenance_type_id"/></td>
<td><span t-field="t.ticket_type" /></td> <td><span t-field="t.severity_type" /></td>
<td><span t-field="t.fail_type" /></td>
<td><span t-field="t.stage_id" /></td> <td><span t-field="t.stage_id" /></td>
</tr> </tr>
</t> </t>
......
...@@ -148,9 +148,18 @@ ...@@ -148,9 +148,18 @@
<em class="font-weight-normal text-muted">Estatus de Respuesta:</em> <em class="font-weight-normal text-muted">Estatus de Respuesta:</em>
<span t-esc="ticket[0].state" /> <span t-esc="ticket[0].state" />
</th> </th>
<th t-if="groupby == 'maintenance_type'">
<em class="font-weight-normal text-muted">Tipo de mantenimiento:</em>
<span t-esc="ticket[0].maintenance_type_id.name" />
</th>
<th t-if="groupby == 'severity_type'">
<em class="font-weight-normal text-muted">Gravedad:</em>
<span t-esc="ticket[0].severity_type" />
</th>
<th>Fecha de creación</th> <th>Fecha de creación</th>
<th>Última actualización</th> <th>Tipo de mantenimiento</th>
<th>Tipo de Ticket</th> <th>Gravedad</th>
<th>Tipo de falla</th>
<th>Estado</th> <th>Estado</th>
</tr> </tr>
</thead> </thead>
...@@ -164,8 +173,9 @@ ...@@ -164,8 +173,9 @@
</a> </a>
</td> </td>
<td><span t-field="t.create_date" t-options='{"widget": "date"}' /></td> <td><span t-field="t.create_date" t-options='{"widget": "date"}' /></td>
<td><span t-field="t.write_date" t-options='{"widget": "date"}' /></td> <td><span t-field="t.maintenance_type_id"/></td>
<td><span t-field="t.ticket_type" /></td> <td><span t-field="t.severity_type" /></td>
<td><span t-field="t.fail_type" /></td>
<td><span t-field="t.stage_id" /></td> <td><span t-field="t.stage_id" /></td>
</tr> </tr>
</t> </t>
......
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
<template id="portal_my_home_menu_ticket" name="Portal layout : ticket menu entries" inherit_id="portal.portal_breadcrumbs" priority="60"> <template id="portal_my_home_menu_ticket" name="Portal layout : ticket menu entries" inherit_id="portal.portal_breadcrumbs" priority="60">
<xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside"> <xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">
<li t-if="page_name == 'maintenance' or maintenance" t-attf-class="breadcrumb-item #{'active ' if not soporte else ''}"> <li t-if="page_name == 'maintenance' or maintenance" t-attf-class="breadcrumb-item #{'active ' if not soporte else ''}">
<a t-if="maintenance" t-attf-href="/my/mantenimientos?{{ keep_query() }}">Mantenimiento</a> <a t-if="maintenance" t-attf-href="/my/mantenimientos?{{ keep_query() }}">Mantenimiento</a>
<t t-else="">Mantenimiento</t> <t t-else="">Mantenimiento</t>
</li> </li>
<li t-if="maintenance" class="breadcrumb-item active"> <li t-if="maintenance" class="breadcrumb-item active">
<t t-esc="maintenance.name" t-if="maintenance.name" /> <t t-esc="maintenance.name" t-if="maintenance" />
<t t-else=""><em>Mantenimiento</em></t> <t t-else=""><em>Mantenimiento</em></t>
</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/mantienimiento/emergencia?{{ keep_query() }}">Emergencia</a>
<t t-else="">Emergencia</t> <t t-else="">Emergencia</t>
...@@ -28,6 +30,7 @@ ...@@ -28,6 +30,7 @@
<t t-esc="maintenance.name" t-if="maintenance.name" /> <t t-esc="maintenance.name" t-if="maintenance.name" />
<t t-else=""><em>Mantenimiento</em></t> <t t-else=""><em>Mantenimiento</em></t>
</li> </li>
</xpath> </xpath>
</template> </template>
......
...@@ -20,8 +20,8 @@ class HomeInherit(Home): ...@@ -20,8 +20,8 @@ class HomeInherit(Home):
if 'login' in kw and 'password' in kw: if 'login' in kw and 'password' in kw:
usr = request.env['res.users'].sudo().search([('login','=',kw['login'])],limit=1) usr = request.env['res.users'].sudo().search([('login','=',kw['login'])],limit=1)
if usr.verification_odoo: if usr.verification_odoo:
response = self.auth_user_rpc(kw['login'],kw['password']) uid = self.auth_user_rpc(kw['login'],kw['password'])
if response['uid'] != 0: if uid != 0:
return super(HomeInherit, self).web_login(redirect=redirect, **kw) return super(HomeInherit, self).web_login(redirect=redirect, **kw)
else: else:
return request.redirect('/web/login?error=access') return request.redirect('/web/login?error=access')
...@@ -30,24 +30,15 @@ class HomeInherit(Home): ...@@ -30,24 +30,15 @@ class HomeInherit(Home):
else: else:
return super(HomeInherit, self).web_login(redirect=redirect, **kw) return super(HomeInherit, self).web_login(redirect=redirect, **kw)
def bearer_token(self,url):
rqst = requests.post(
url+"t06k3n/",
data={"uu89ieor18u":USER,"2dpsonid45p":PASSW}
)
response = rqst.json()
return response['t0k3n']
def auth_user_rpc(self,username,password): def auth_user_rpc(self,username,password):
company = request.env['res.company'].sudo().search([], limit=1) uid = 0
url = company.login_url+"/api/v1/" companies_url = request.env['res.company'].sudo().search([]).filtered(lambda c: c.login_url and c.login_db)
rqst = requests.get( if companies_url:
url+"helpdeskuser/", for c in companies_url:
headers={'Authorization': 'Bearer '+self.bearer_token(url)}, common = xmlrpc.client.ServerProxy(c.login_url+"/xmlrpc/2/common")
data={"user":username,"password":password} uid = common.authenticate(c.login_db,username,password,{})
) if uid != 0:
return rqst.json() break
return uid
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import UserError from odoo.exceptions import UserError
import requests
USER = "helpdesk"
PASSW = "12345"
class ResCompany(models.Model): class ResCompany(models.Model):
_inherit = 'res.company' _inherit = 'res.company'
login_url = fields.Char('URL') login_url = fields.Char('URL')
login_db = fields.Char('Base de Datos')
def test_conn(self):
url = self.login_url+"/api/v1/"
request = requests.post(
url+"t06k3n/",
data={"uu89ieor18u":USER,"2dpsonid45p":PASSW}
)
response = request.json()
if response['t0k3n']:
pass
else:
raise UserError('CONEXIÓN ERRONEA')
\ No newline at end of file
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