Commit 9f2f95d3 by Arturo Jasso Origel

se agrego apartado para ocultar el log as superuser, y se puso invisbleel campo…

se agrego apartado para ocultar el log as superuser, y se puso invisbleel campo en res users de acceso al portal el cual no se estaba haciendo uso
parent 4935a933
$(document).ready(function(e) { $(document).ready(function(e) {
$("#portal_date_fail").datepicker(); $("#portal_date_fail").datepicker();
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"){
...@@ -118,7 +118,7 @@ $(document).ready(function(e) { ...@@ -118,7 +118,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");
...@@ -139,7 +139,7 @@ $(document).ready(function(e) { ...@@ -139,7 +139,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");
......
...@@ -72,18 +72,13 @@ ...@@ -72,18 +72,13 @@
<label class="control-label" for="portal_sucursal">Sucursal:</label> <label class="control-label" for="portal_sucursal">Sucursal:</label>
<select class="form-control form-field o_website_form_required_custom" id="portal_sucursal" name="portal_sucursal" t-att-value="request.env.user.warehouse_id.id"> <select class="form-control form-field o_website_form_required_custom" id="portal_sucursal" name="portal_sucursal" t-att-value="request.env.user.warehouse_id.id">
<option> </option> <option> </option>
<t t-if="len(request.env['warehouse.helpdesk'].sudo().search([('id','in',request.env.user.warehouse_ids.ids)])) == 1"> <t t-foreach="request.env['warehouse.helpdesk'].sudo().search([])" t-as="suc">
<t t-foreach="request.env['warehouse.helpdesk'].sudo().search([('id','in',request.env.user.warehouse_ids.ids)])" t-as="suc">
<option t-att-value="suc.id"><t t-esc="suc.name" /></option> <option t-att-value="suc.id"><t t-esc="suc.name" /></option>
</t> </t>
</t>
<t t-else="">
<t t-foreach="request.env['warehouse.helpdesk'].sudo().search([('id','in',request.env.user.warehouse_ids.ids)])" t-as="suc">
<option t-att-value="suc.id"><t t-esc="suc.name" /></option>
</t>
</t>
</select> </select>
</div> </div>
<div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_module' in error and 'has-error' or ''}"> <div t-attf-class="form-group o_website_form_required_custom #{error and 'portal_module' in error and 'has-error' or ''}">
<label class="control-label" for="portal_module">Módulo:</label> <label class="control-label" for="portal_module">Módulo:</label>
<select class="form-control form-field o_website_form_required_custom" id="portal_module" name="portal_module"> <select class="form-control form-field o_website_form_required_custom" id="portal_module" name="portal_module">
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
{ {
"name":"Odoo Api Change Passowrod", "name":"Odoo Other Login",
"author":"Arturo Jasso", "author":"Arturo Jasso",
"website":"", "website":"",
"support":"arturo.jasso@morsa.com.mx", "support":"arturo.jasso@morsa.com.mx",
"category":"", "category":"",
"license":"OPL-1", "license":"OPL-1",
"summary":"Cambio de contraseña", "summary":"Cambio de contraseña",
"description":"""Actualización de contraseña a odoo""", "description":"""Verificación de login de odoo""",
"version":"15.0.34", "version":"15.0.34",
"depends": [ "depends": [
"base", "base",
......
import json import json
import logging import logging
import requests
import xmlrpc.client import xmlrpc.client
import odoo import odoo
import odoo.modules.registry import odoo.modules.registry
...@@ -9,7 +10,8 @@ from odoo.exceptions import AccessError ...@@ -9,7 +10,8 @@ from odoo.exceptions import AccessError
from odoo.http import request from odoo.http import request
from odoo.addons.web.controllers.main import Home from odoo.addons.web.controllers.main import Home
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
USER = "helpdesk"
PASSW = "12345"
class HomeInherit(Home): class HomeInherit(Home):
...@@ -18,8 +20,8 @@ class HomeInherit(Home): ...@@ -18,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:
uid = self.auth_user_rpc(kw['login'],kw['password']) response = self.auth_user_rpc(kw['login'],kw['password'])
if uid != 0: if response['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')
...@@ -28,14 +30,24 @@ class HomeInherit(Home): ...@@ -28,14 +30,24 @@ 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):
uid = 0 company = request.env['res.company'].sudo().search([], limit=1)
companies_url = request.env['res.company'].sudo().search([]).filtered(lambda c: c.login_url and c.login_db) url = company.login_url+"/api/v1/"
if companies_url: rqst = requests.get(
for c in companies_url: url+"helpdeskuser/",
common = xmlrpc.client.ServerProxy(c.login_url+"/xmlrpc/2/common") headers={'Authorization': 'Bearer '+self.bearer_token(url)},
uid = common.authenticate(c.login_db,username,password,{}) data={"user":username,"password":password}
if uid != 0: )
break return rqst.json()
return uid
...@@ -10,12 +10,4 @@ class ResUsersInherit(models.Model): ...@@ -10,12 +10,4 @@ class ResUsersInherit(models.Model):
verification_odoo = fields.Boolean('Verificación de Usuario') verification_odoo = fields.Boolean('Verificación de Usuario')
"""def change_password_api(self,login,new_password):
res = {"res":200,"message":"Actualización completa"} \ No newline at end of file
user = self.env['res.users'].sudo().search([('login','=',login)])
if user:
user.sudo().write({'password':new_password})
else:
res = {"res":400,"message":"Fallida"}
return res
"""
\ No newline at end of file
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
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<group> <group>
<group> <group>
<field name="login_url"/> <field name="login_url"/>
<field name="login_db"/> <button name="test_conn" type="object" string="Probar conexión" class="oe_highlight" />
</group> </group>
</group> </group>
</page> </page>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"depends": [ "depends": [
"base", "base",
"portal", "portal",
'web',
"account", "account",
"sale", "sale",
"purchase", "purchase",
......
...@@ -5,4 +5,11 @@ ...@@ -5,4 +5,11 @@
<div></div> <div></div>
</xpath> </xpath>
</template> </template>
<template id="web_login_remove" name="template_name" inherit_id="web.login">
<xpath expr="//t[@t-if='debug']" position="replace">
</xpath>
</template>
</odoo> </odoo>
\ No newline at end of file
...@@ -745,5 +745,7 @@ ...@@ -745,5 +745,7 @@
<field name="lang">{{object.partner_id.lang}}</field> <field name="lang">{{object.partner_id.lang}}</field>
<field name="auto_delete" eval="False" /> <field name="auto_delete" eval="False" />
</record> </record>
</data> </data>
</odoo> </odoo>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_title')]//field[@name='partner_id']" position="after"> <xpath expr="//div[hasclass('oe_title')]//field[@name='partner_id']" position="after">
<field name="sh_portal_user" invisible="1" /> <field name="sh_portal_user" invisible="1" />
<field name="sh_portal_user_access" attrs="{'invisible':[('sh_portal_user','=',False)]}" /> <field name="sh_portal_user_access" invisible="1" />
</xpath> </xpath>
</field> </field>
</record> </record>
......
...@@ -8,9 +8,11 @@ odoo.define('vista_backend_theme.SideBar', function (require) { ...@@ -8,9 +8,11 @@ odoo.define('vista_backend_theme.SideBar', function (require) {
template: "vista_backend_theme.Sidebar", template: "vista_backend_theme.Sidebar",
init: function (parent, menuData) { init: function (parent, menuData) {
console.log(menuData)
this._super.apply(this, arguments); this._super.apply(this, arguments);
console.log(this._super.apply(this, arguments));
this._apps = _.map(menuData.children, function (appMenuData) { this._apps = _.map(menuData.children, function (appMenuData) {
console.log(appMenuData)
return { return {
actionID: parseInt(appMenuData.action.split(',')[1]), actionID: parseInt(appMenuData.action.split(',')[1]),
menuID: appMenuData.id, menuID: appMenuData.id,
...@@ -19,6 +21,7 @@ odoo.define('vista_backend_theme.SideBar', function (require) { ...@@ -19,6 +21,7 @@ odoo.define('vista_backend_theme.SideBar', function (require) {
web_icon_data: appMenuData.web_icon_data, web_icon_data: appMenuData.web_icon_data,
}; };
}); });
console.log(this._apps);
}, },
getApps: function () { getApps: function () {
......
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
</a> </a>
</li> </li>
</t> </t>
</ul> </ul>
</div> </div>
......
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