@ -1,9 +1,10 @@ |
|||||
## Module <hide_menu_user> |
## Module <hide_menu_user> |
||||
|
|
||||
#### 15.07.2021 |
#### 15.07.2021 |
||||
#### Version 14.0.1.0.0 |
#### Version 14.0.1.0.0 |
||||
#### ADD |
#### ADD |
||||
- Initial commit for hide_menu_user |
- Initial commit for hide_menu_user |
||||
|
|
||||
|
### 24.02.2023 |
||||
|
### Version 14.0.1.1.1 |
||||
|
### ADD |
||||
|
- Added a new feature, to import the list of hide specific menus |
||||
|
@ -0,0 +1,30 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
|
||||
|
from odoo import models, fields |
||||
|
|
||||
|
|
||||
|
class RestrictMenu(models.Model): |
||||
|
""" Inherited Menu Items""" |
||||
|
_inherit = 'ir.ui.menu' |
||||
|
|
||||
|
restrict_user_ids = fields.Many2many('res.users', store=True) |
|
@ -1,9 +1,8 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
<odoo> |
<odoo> |
||||
|
|
||||
<record id="restrict_menu_user" model="ir.rule"> |
<record id="restrict_menu_user" model="ir.rule"> |
||||
<field name="name">Restrict Menu from Users</field> |
<field name="name">Restrict Menu from Users</field> |
||||
<field ref="model_ir_ui_menu" name="model_id"/> |
<field ref="model_ir_ui_menu" name="model_id"/> |
||||
<field name="domain_force">[('restrict_user_ids','not in',user.id)]</field> |
<field name="domain_force">[('restrict_user_ids','not in',user.id)]</field> |
||||
</record> |
</record> |
||||
|
</odoo> |
||||
</odoo> |
|
||||
|
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 165 KiB |
After Width: | Height: | Size: 242 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 180 KiB |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
|
||||
|
from . import import_menu_list |
@ -0,0 +1,28 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<record id="import_menu_list_wizard_view_form" model="ir.ui.view"> |
||||
|
<field name="name">import.menu.list.form</field> |
||||
|
<field name="model">import.menu.list.wizard</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Test"> |
||||
|
<group class="oe_title"> |
||||
|
<field name="name" readonly="1"/> |
||||
|
<field name="user_id" invisible="1"/> |
||||
|
<field name="import_file"/> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="action_import_xls" string="Import" type="object" class="oe_highlight"/> |
||||
|
<button string="Cancel" class="btn-secondary" special="cancel"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
<record id="import_menu_list_wizard_action" model="ir.actions.act_window"> |
||||
|
<field name="name">Import Menu List</field> |
||||
|
<field name="type">ir.actions.act_window</field> |
||||
|
<field name="res_model">import.menu.list.wizard</field> |
||||
|
<field name="view_mode">form</field> |
||||
|
<field name="view_id" ref="import_menu_list_wizard_view_form"/> |
||||
|
<field name="target">new</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,71 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
|
||||
|
import base64 |
||||
|
import openpyxl |
||||
|
from io import BytesIO |
||||
|
from odoo import models, fields, _ |
||||
|
from odoo.exceptions import UserError |
||||
|
|
||||
|
|
||||
|
class OrderLinesWizard(models.TransientModel): |
||||
|
""" This class contain the fields of wizard and it will import the xslx file""" |
||||
|
_name = 'import.menu.list.wizard' |
||||
|
_description = "Import the menu list" |
||||
|
|
||||
|
name = fields.Char(string="Name", Readonly=True) |
||||
|
import_file = fields.Binary(string="Upload Files", help="Select the xlsx file to import ") |
||||
|
user_id = fields.Integer(string="User Id") |
||||
|
|
||||
|
def action_import_xls(self): |
||||
|
"""This function will help to import the Excel sheet""" |
||||
|
try: |
||||
|
wb = openpyxl.load_workbook( |
||||
|
filename=BytesIO(base64.b64decode(self.import_file)), read_only=True |
||||
|
) |
||||
|
ws = wb.active |
||||
|
except: |
||||
|
raise UserError( |
||||
|
_('Please insert a valid file')) |
||||
|
|
||||
|
col = -1 |
||||
|
flag = 0 |
||||
|
for rec in ws.iter_rows(min_row=1, max_row=1, min_col=None, max_col=None, values_only=True): |
||||
|
for head in rec: |
||||
|
col = col + 1 |
||||
|
if head == 'Parent Path': |
||||
|
flag = 1 |
||||
|
break |
||||
|
if flag == 0: |
||||
|
raise UserError( |
||||
|
_('Please insert a parent path in the file')) |
||||
|
for record in ws.iter_rows(min_row=2, max_row=None, min_col=None, max_col=None, values_only=True): |
||||
|
menu_exist = self.env['ir.ui.menu'].search([('parent_path', '=', record[col])]).id |
||||
|
if not menu_exist: |
||||
|
raise UserError( |
||||
|
_('Please have valid parent path')) |
||||
|
res = { |
||||
|
'res_users_id': self.user_id, |
||||
|
'ir_ui_menu_id': menu_exist, |
||||
|
} |
||||
|
self.env['res.users'].search([('id', '=', res['res_users_id'])]).write( |
||||
|
{'hide_menu_ids': [(4, res['ir_ui_menu_id'])]}) |