Commit 2646e526 by Arturo Jasso Origel

se escondieron los menus para los usuarios que no tengan el valor de…

se escondieron los menus para los usuarios que no tengan el valor de only_all_app como falsos, y se corrigio bug de icono de hoja de horas, además de que se retiro la brocha de la vista
parent ac0cc866
......@@ -5,4 +5,10 @@ class ResUsersVista(models.Model):
_inherit = 'res.users'
only_all_app = fields.Boolean('Ver apps')
\ No newline at end of file
@api.model
def apps_permission(self,user):
user = self.browse(user)
show = 'show' if user.only_all_app == True else 'hide'
return show
\ No newline at end of file
odoo.define('vista_backend_theme.SideBar', function (require) {
"use strict";
var Widget = require('web.Widget');
var SideBar = Widget.extend({
events: _.extend({}, Widget.prototype.events, {
'click .nav-link': '_onAppsMenuItemClicked',
}),
template: "vista_backend_theme.Sidebar",
init: function (parent, menuData) {
this._super.apply(this, arguments);
this._apps = _.map(menuData.children, function (appMenuData) {
return {
actionID: parseInt(appMenuData.action.split(',')[1]),
menuID: appMenuData.id,
......@@ -21,9 +22,8 @@ odoo.define('vista_backend_theme.SideBar', function (require) {
web_icon_data: appMenuData.web_icon_data,
};
});
},
getApps: function () {
return this._apps;
},
......
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="theme_systray">
<li class="new_icon">
<!--<li class="new_icon">
<label class="theme_vista" style="margin-bottom:0px;" title="Change backend theme">
<t t-if="widget.is_admin">
<div class="icon_div">
......@@ -11,6 +11,6 @@
</div>
</t>
</label>
</li>
</li>-->
</t>
</templates>
\ No newline at end of file
......@@ -53,11 +53,11 @@
<img src="/code_backend_theme/static/src/img/icons/close.png"/>
</a>
</div>
<h6 class="sidebar_head">MENU</h6>
<ul class="sidebar_menu">
<t t-foreach="menuService.getApps()" t-as="app">
<t t-if="app.name == 'Mesa de ayuda' or app.name == 'Ajustes'">
<li data-toggle="tooltip" data-placement="right" t-att-title="app.name">
<a role="menuitem"
t-attf-href="#menu_id={{app.id}}"
......@@ -72,12 +72,81 @@
</a>
</li>
</t>
<t t-else="">
<li data-toggle="tooltip" data-placement="right" t-att-title="app.name" groups="vista_backend_theme.show_all_apps">
<a role="menuitem"
t-attf-href="#menu_id={{app.id}}"
class="nav-link"
>
<img class="sidebar_img"
t-attf-src="data:image/png;base64,{{app.webIconData}}"/>
<span class="sidebar_app_name">
<t t-esc="app.name"/>
</span>
</a>
</li>
</t>
</t>
</ul>
</div>
<script>
odoo.define('vista_backend_theme.user', function(require) {
"use strict";
var session = require('web.session');
var rpc = require('web.rpc');
var user_id = session.uid;
console.log('El ID de usuario actual es:', user_id);
rpc.query({
model: 'res.users',
method: 'apps_permission',
args: [user_id],
}).then(function(resultado) {
if (resultado != 'show'){
$('.sidebar_menu li').each(function() {
var titulo = $(this).attr('title');
if (titulo == 'Mesa de ayuda' || titulo == 'Ajustes' || titulo == 'Aplicaciones'){
console.log(titulo);
}else{
$(this).addClass('d-none');
}
});
}
});
if (user_id != 2){
$('.sidebar_menu li').each(function() {
var titulo = $(this).attr('title');
if (titulo == 'Mesa de ayuda' || titulo == 'Ajustes' || titulo == 'Aplicaciones'){
console.log(titulo);
}else{
$(this).addClass('d-none');
}
});
}
});
/**/
</script>
</div>
</xpath>
</t>
......
......@@ -4,11 +4,13 @@
<record model="ir.ui.view" id="res_users_inherit_only_app">
<field name="name">res.users.form.inherit.partner</field>
<field name="model">res.users</field>
<field name="priority" eval="20"/>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="inherit_id" ref="base.user_groups_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="only_all_app"/>
<xpath expr="//group[1]" position="inside">
<field name="only_all_app"/>
</xpath>
</field>
</record>
......
......@@ -4,6 +4,10 @@ import base64
from odoo import models, fields, api
from odoo.modules import get_module_resource
import logging
_logger = logging.getLogger(__name__)
class Theme(models.TransientModel):
_name = "theme.data"
......@@ -56,6 +60,7 @@ class Theme(models.TransientModel):
def icon_change_theme_default(self):
menu_item = self.env['ir.ui.menu'].sudo().search([('parent_id', '=', False)])
for menu in menu_item:
if menu.name == 'Contacts':
img_path = get_module_resource(
'vista_backend_theme', 'static', 'src', 'img', 'icons',
......@@ -225,9 +230,11 @@ class Theme(models.TransientModel):
menu.write({'web_icon_data': base64.b64encode(
open(img_path, "rb").read())})
if menu.name == 'Timesheets':
img_path = get_module_resource(
'vista_backend_theme', 'static', 'src', 'img', 'icons',
'timesheets.png')
'timesheet.png')
menu.write({'web_icon_data': base64.b64encode(
open(img_path, "rb").read())})
if menu.name == 'Events':
......
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