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): ...@@ -5,4 +5,10 @@ class ResUsersVista(models.Model):
_inherit = 'res.users' _inherit = 'res.users'
only_all_app = fields.Boolean('Ver apps') 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) { odoo.define('vista_backend_theme.SideBar', function (require) {
"use strict"; "use strict";
var Widget = require('web.Widget'); var Widget = require('web.Widget');
var SideBar = Widget.extend({ var SideBar = Widget.extend({
events: _.extend({}, Widget.prototype.events, { events: _.extend({}, Widget.prototype.events, {
'click .nav-link': '_onAppsMenuItemClicked', 'click .nav-link': '_onAppsMenuItemClicked',
}), }),
template: "vista_backend_theme.Sidebar", template: "vista_backend_theme.Sidebar",
init: function (parent, menuData) { init: function (parent, menuData) {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this._apps = _.map(menuData.children, function (appMenuData) { this._apps = _.map(menuData.children, function (appMenuData) {
return { return {
actionID: parseInt(appMenuData.action.split(',')[1]), actionID: parseInt(appMenuData.action.split(',')[1]),
menuID: appMenuData.id, menuID: appMenuData.id,
...@@ -21,9 +22,8 @@ odoo.define('vista_backend_theme.SideBar', function (require) { ...@@ -21,9 +22,8 @@ odoo.define('vista_backend_theme.SideBar', function (require) {
web_icon_data: appMenuData.web_icon_data, web_icon_data: appMenuData.web_icon_data,
}; };
}); });
}, },
getApps: function () { getApps: function () {
return this._apps; return this._apps;
}, },
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<templates> <templates>
<t t-name="theme_systray"> <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"> <label class="theme_vista" style="margin-bottom:0px;" title="Change backend theme">
<t t-if="widget.is_admin"> <t t-if="widget.is_admin">
<div class="icon_div"> <div class="icon_div">
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
</div> </div>
</t> </t>
</label> </label>
</li> </li>-->
</t> </t>
</templates> </templates>
\ No newline at end of file
...@@ -53,11 +53,11 @@ ...@@ -53,11 +53,11 @@
<img src="/code_backend_theme/static/src/img/icons/close.png"/> <img src="/code_backend_theme/static/src/img/icons/close.png"/>
</a> </a>
</div> </div>
<h6 class="sidebar_head">MENU</h6> <h6 class="sidebar_head">MENU</h6>
<ul class="sidebar_menu"> <ul class="sidebar_menu">
<t t-foreach="menuService.getApps()" t-as="app"> <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"> <li data-toggle="tooltip" data-placement="right" t-att-title="app.name">
<a role="menuitem" <a role="menuitem"
t-attf-href="#menu_id={{app.id}}" t-attf-href="#menu_id={{app.id}}"
...@@ -72,12 +72,81 @@ ...@@ -72,12 +72,81 @@
</a> </a>
</li> </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> </t>
</ul> </ul>
</div> </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> </div>
</xpath> </xpath>
</t> </t>
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
<record model="ir.ui.view" id="res_users_inherit_only_app"> <record model="ir.ui.view" id="res_users_inherit_only_app">
<field name="name">res.users.form.inherit.partner</field> <field name="name">res.users.form.inherit.partner</field>
<field name="model">res.users</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"> <field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after"> <xpath expr="//group[1]" position="inside">
<field name="only_all_app"/>
<field name="only_all_app"/>
</xpath> </xpath>
</field> </field>
</record> </record>
......
...@@ -4,6 +4,10 @@ import base64 ...@@ -4,6 +4,10 @@ import base64
from odoo import models, fields, api from odoo import models, fields, api
from odoo.modules import get_module_resource from odoo.modules import get_module_resource
import logging
_logger = logging.getLogger(__name__)
class Theme(models.TransientModel): class Theme(models.TransientModel):
_name = "theme.data" _name = "theme.data"
...@@ -56,6 +60,7 @@ class Theme(models.TransientModel): ...@@ -56,6 +60,7 @@ class Theme(models.TransientModel):
def icon_change_theme_default(self): def icon_change_theme_default(self):
menu_item = self.env['ir.ui.menu'].sudo().search([('parent_id', '=', False)]) menu_item = self.env['ir.ui.menu'].sudo().search([('parent_id', '=', False)])
for menu in menu_item: for menu in menu_item:
if menu.name == 'Contacts': if menu.name == 'Contacts':
img_path = get_module_resource( img_path = get_module_resource(
'vista_backend_theme', 'static', 'src', 'img', 'icons', 'vista_backend_theme', 'static', 'src', 'img', 'icons',
...@@ -225,9 +230,11 @@ class Theme(models.TransientModel): ...@@ -225,9 +230,11 @@ class Theme(models.TransientModel):
menu.write({'web_icon_data': base64.b64encode( menu.write({'web_icon_data': base64.b64encode(
open(img_path, "rb").read())}) open(img_path, "rb").read())})
if menu.name == 'Timesheets': if menu.name == 'Timesheets':
img_path = get_module_resource( img_path = get_module_resource(
'vista_backend_theme', 'static', 'src', 'img', 'icons', 'vista_backend_theme', 'static', 'src', 'img', 'icons',
'timesheets.png') 'timesheet.png')
menu.write({'web_icon_data': base64.b64encode( menu.write({'web_icon_data': base64.b64encode(
open(img_path, "rb").read())}) open(img_path, "rb").read())})
if menu.name == 'Events': 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