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