Browse Source

Add module base_import_module_group

12.0-mig-module_prototyper_last
Akim Juillerat 4 years ago
parent
commit
d10eab5dbb
  1. 0
      base_import_module_group/README.rst
  2. 2
      base_import_module_group/__init__.py
  3. 21
      base_import_module_group/__manifest__.py
  4. 1
      base_import_module_group/models/__init__.py
  5. 20
      base_import_module_group/models/ir_module.py
  6. 2
      base_import_module_group/readme/CONTRIBUTORS.rst
  7. 2
      base_import_module_group/readme/DESCRIPTION.rst
  8. 10
      base_import_module_group/security/res_groups.xml
  9. 11
      base_import_module_group/views/import_module_group.xml

0
base_import_module_group/README.rst

2
base_import_module_group/__init__.py

@ -0,0 +1,2 @@
from . import models

21
base_import_module_group/__manifest__.py

@ -0,0 +1,21 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{
"name": "Import Module Group",
"summary": "Restrict module importation to specific group",
"version": "12.0.1.0.0",
"category": "Uncategorized",
"website": "https://github.com/OCA/server-tools",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"auto-install": True,
"depends": [
"base_import_module",
],
"data": [
"security/res_groups.xml",
"views/import_module_group.xml",
],
}

1
base_import_module_group/models/__init__.py

@ -0,0 +1 @@
from . import ir_module

20
base_import_module_group/models/ir_module.py

@ -0,0 +1,20 @@
# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import _, api, models
from odoo.exceptions import AccessError
class IrModule(models.Model):
_inherit = 'ir.module.module'
@api.multi
def _import_module(self, module, path, force=False):
group_xid = 'import_module_group.group_module_import'
if not self.env.user.has_group(group_xid):
group = self.env.ref(group_xid)
raise AccessError(
_("Only users with group %s are allowed to import modules")
% group.name
)
return super()._import_module(module, path, force=force)

2
base_import_module_group/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>

2
base_import_module_group/readme/DESCRIPTION.rst

@ -0,0 +1,2 @@
This module adds a security group to restrict importation of users
to members of this specific group.

10
base_import_module_group/security/res_groups.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo noupdate="1">
<record model="res.groups" id="group_module_import">
<field name="name">Allow importation of modules</field>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
<record model="res.groups" id="base.group_system">
<field name="implied_ids" eval="[(4, ref('group_module_import'))]" />
</record>
</odoo>

11
base_import_module_group/views/import_module_group.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="import_module_view_action" model="ir.actions.act_window">
<field name="name">Import Module</field>
<field name="res_model">base.import.module</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem id="import_module_menuitem" name="Import Module" action="import_module_view_action" parent="base.menu_administration" groups="base_import_module_group.group_module_import"/>
</odoo>
Loading…
Cancel
Save