Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions base_user_role_import/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
=====================
Base User Role Import
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d96a7c73bcab66dc75f18a87fad00f29534febbf874f042d4fca3f49f647a884
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/18.0/base_user_role_import
:alt: OCA/server-backend
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-backend-18-0/server-backend-18-0-base_user_role_import
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module bridges ``base_import_manager`` and
``base_user_role_extended`` to enable role-based import control.

1. It integrates the "Import Access" permission field on model access
rights (``ir.model.access``) with user roles.
2. It dynamically enforces the import permission restriction based on
the user's active Roles.
3. Supports role policy bypass for superusers.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure role-based import access:

1. Go to **Settings > Users & Companies > Roles** and select the Role
you want to configure.
2. Identify the implied Groups that grant access to the relevant models.
3. Edit the Group's **Access Rights** tab.
4. Set the **Import Access** field for the model access rules under that
Group.

All permitted import permissions from the groups implied by a user's
active Roles will be automatically aggregated and dynamically enforced.

Usage
=====

Once role-based import access is configured:

1. Log in as a user who has active Roles where none of the implied
groups grant "Import Access" for a specific model.
2. Go to the list or kanban view for that model.
3. The "Import" option will not be displayed or accessible in the user
interface.

Known issues / Roadmap
======================

- None.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_user_role_import%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* CIT Services

Contributors
------------

- `CIT-Services <cit-services.eu>`__

- Prayag <prayag.k@cit-services.eu>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/18.0/base_user_role_import>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions base_user_role_import/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 CIT Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
16 changes: 16 additions & 0 deletions base_user_role_import/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2026 CIT Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Base User Role Import",
"summary": "Bridge base_import_manager with base_user_role_extended",
"category": "Tools",
"version": "18.0.1.0.0",
"depends": ["base_import_manager", "base_user_role_extended"],
"website": "https://github.com/OCA/server-backend",
"author": "CIT Services, Odoo Community Association (OCA)",
"data": [],
"installable": True,
"application": False,
"license": "AGPL-3",
}
5 changes: 5 additions & 0 deletions base_user_role_import/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2026 CIT Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import ir_ui_view
from . import res_users_role
22 changes: 22 additions & 0 deletions base_user_role_import/models/ir_ui_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 CIT Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class IrUiView(models.Model):
_inherit = "ir.ui.view"

def _get_import_group_ids(self):
"""Get group IDs representing active user roles for import check."""
user = self.env.user
if user.bypass_role_policy:
return super()._get_import_group_ids()

active_roles = user.role_line_ids.filtered(lambda r: r.is_enabled).mapped(
"role_id"
)
if active_roles:
return active_roles.mapped("group_id").ids

return super()._get_import_group_ids()
14 changes: 14 additions & 0 deletions base_user_role_import/models/res_users_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2026 CIT Services
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class ResUsersRole(models.Model):
_inherit = "res.users.role"

def collect_all_perm_fields(self, perm_fields=None):
"""Include `perm_import` in the synchronized permission fields."""
perm_fields = perm_fields or {}
perm_fields.setdefault("perm_import", False)
return super().collect_all_perm_fields(perm_fields=perm_fields)
4 changes: 4 additions & 0 deletions base_user_role_import/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions base_user_role_import/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To configure role-based import access:

1. Go to **Settings > Users & Companies > Roles** and select the Role you want to configure.
2. Identify the implied Groups that grant access to the relevant models.
3. Edit the Group's **Access Rights** tab.
4. Set the **Import Access** field for the model access rules under that Group.

All permitted import permissions from the groups implied by a user's active Roles will be automatically aggregated and dynamically enforced.
2 changes: 2 additions & 0 deletions base_user_role_import/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [CIT-Services](cit-services.eu)
- Prayag \<<prayag.k@cit-services.eu>\>
5 changes: 5 additions & 0 deletions base_user_role_import/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module bridges `base_import_manager` and `base_user_role_extended` to enable role-based import control.

1. It integrates the "Import Access" permission field on model access rights (`ir.model.access`) with user roles.
2. It dynamically enforces the import permission restriction based on the user's active Roles.
3. Supports role policy bypass for superusers.
1 change: 1 addition & 0 deletions base_user_role_import/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- None.
5 changes: 5 additions & 0 deletions base_user_role_import/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Once role-based import access is configured:

1. Log in as a user who has active Roles where none of the implied groups grant "Import Access" for a specific model.
2. Go to the list or kanban view for that model.
3. The "Import" option will not be displayed or accessible in the user interface.
Loading