Skip to content
Extraits de code Groupes Projets
Valider c34a80bd rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[init] module init

parent
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
.*
*.pyc
!.gitignore
Ce diff est replié.
.. image:: https://img.shields.io/badge/licence-GPL--3-blue.svg
:target: http://www.gnu.org/licenses/gpl
:alt: License: AGPL-3
===================
Multi Company Menus
===================
Description
===========
This module adds as M2M company field to menu item. If this field is not empty, the menu visibility will be based on companies, groups and access rights. If this field is empty, Odoo will compute visibility based on the related object and group's read access.
Configuration
=============
Go to *Configuration > Technical > Menus* and add allowed companies to a menu.
Credits
=======
Contributors
------------
* Benjamin Rivier <benjamin@le-filament.com>
Maintainer
----------
.. image:: https://le-filament.com/img/logo-lefilament.png
:alt: Le Filament
:target: https://le-filament.com
This module is maintained by Le Filament
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Multi-Company Menus",
"summary": "Allows companies on menus",
"version": "12.0.1.0.0",
"author": "Le Filament",
"category": "Base",
"license": "AGPL-3",
"depends": ["base",],
"demo": [],
'data': [
'views/ir_ui_menu.xml',
],
"installable": True,
"auto_install": False,
}
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * multi_company_menu
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-19 14:51+0000\n"
"PO-Revision-Date: 2021-01-19 14:51+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: multi_company_menu
#: model:ir.model.fields,field_description:multi_company_menu.field_ir_ui_menu__company_ids
#: model_terms:ir.ui.view,arch_db:multi_company_menu.edit_menu_access
msgid "Companies"
msgstr "Sociétés"
#. module: multi_company_menu
#: model:ir.model.fields,help:multi_company_menu.field_ir_ui_menu__company_ids
msgid "If you have companies, the visibility of this menu will be based on these companies. If this field is empty, Odoo will compute visibility based on the related object's read access."
msgstr "Si des sociétés sont configurées, ce menu ne sera accessible que pour ces sociétés. Si ce champ est vide, le menu est accessible pour toutes les sociétés."
#. module: multi_company_menu
#: model:ir.model,name:multi_company_menu.model_ir_ui_menu
msgid "Menu"
msgstr "Menu"
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import ir_ui_menu
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models, api, tools
class IrUiMenuMultiCompany(models.Model):
_inherit = 'ir.ui.menu'
company_ids = fields.Many2many(
comodel_name='res.company',
relation='ir_ui_menu_company_rel',
column1='menu_id',
column2='company_id',
string='Companies',
help="If you have companies, the visibility of this menu will be "
"based on these companies. "
"If this field is empty, Odoo will compute visibility based on "
"the related object's read access.")
@api.model
@tools.ormcache('frozenset(self.env.user.groups_id.ids)', 'debug')
def _visible_menu_ids(self, debug=False):
"""
Adds companies constraint on menus
:param debug: if debug enabled
:return: set(menu_ids)
"""
menus = super(IrUiMenuMultiCompany, self)._visible_menu_ids(debug)
menu_ids = self.browse(list(menus))
visible_menu_ids = menu_ids
company_id = self.env.user.company_id
for menu in menu_ids:
if menu.company_ids and company_id not in menu.company_ids:
visible_menu_ids = visible_menu_ids - menu
return set(visible_menu_ids.ids)
static/description/icon.png

8,95 ko

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 Le Filament
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="edit_menu_access">
<field name="inherit_id" ref="base.edit_menu_access"/>
<field name="name">ir.ui.menu.form</field>
<field name="model">ir.ui.menu</field>
<field name="arch" type="xml">
<notebook position="inside">
<page name="company_menus" string="Companies">
<field name="company_ids"/>
</page>
</notebook>
</field>
</record>
</odoo>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter