Commit 3f72f378 by Arturo Jasso Origel

restableciendo cambios de other_odoo_login

parent 5d9ba670
<?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>
...@@ -9,5 +9,13 @@ ...@@ -9,5 +9,13 @@
<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')
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