Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] base_user_role_company: Migration to 18.0 #328

Open
wants to merge 44 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
89d46c0
[ADD] base_user_role_company: add per company user roles
Chandresh-OSI May 3, 2021
db94e61
[UPD] Update base_user_role_company.pot
oca-travis May 19, 2021
6dc1448
[UPD] README.rst
OCA-git-bot May 19, 2021
32fea02
[ADD] icon.png
OCA-git-bot May 19, 2021
1f965d6
[FIX] base_user_role_company: wrong xpath
kos94ok-3D Nov 3, 2021
52fd60f
base_user_role_company 14.0.1.1.0
OCA-git-bot Nov 4, 2021
e508f28
Added translation using Weblate (Italian)
Feb 15, 2022
1066e12
[FIX] base_user_role_company: roles not properly applied on login
dreispt Feb 15, 2022
d612a61
Translated using Weblate (Italian)
Feb 15, 2022
6172a02
[FIX] base_user_role_company: wrong menus on re-login
dreispt Mar 2, 2022
4f524f3
[FIX] base_user_role_company: fix tests
dreispt Mar 3, 2022
c095f3f
[UPD] Update base_user_role_company.pot
oca-travis Mar 3, 2022
af551c9
base_user_role_company 14.0.2.0.0
OCA-git-bot Mar 3, 2022
d76e34c
Update translation files
oca-transbot Mar 3, 2022
51fec33
base_user_role_company 14.0.2.0.1
OCA-git-bot Mar 3, 2022
a0ab32c
Translated using Weblate (Italian)
francesco-ooops Mar 7, 2023
ce0aaa6
[IMP] base_user_role_company: pre-commit stuff
Urvisha-OSI Apr 5, 2023
11ca4f6
[MIG] base_user_role_company: Migration to 16.0
Urvisha-OSI Apr 5, 2023
8123f34
[UPD] Update base_user_role_company.pot
Aug 7, 2023
d3941e6
[UPD] README.rst
OCA-git-bot Aug 7, 2023
126be0b
Update translation files
weblate Aug 7, 2023
ef6f1a0
Added translation using Weblate (Spanish)
Ivorra78 Aug 25, 2023
2a965ee
Translated using Weblate (Spanish)
Ivorra78 Aug 25, 2023
19eb997
Added translation using Weblate (Portuguese)
pedrocs-exo Aug 31, 2023
c0b3718
Translated using Weblate (Portuguese)
pedrocs-exo Aug 31, 2023
52e773c
[UPD] README.rst
OCA-git-bot Sep 3, 2023
3bbfdde
[FIX] base_user_role_company: Pylint fix
etobella Oct 28, 2023
a964be3
[UPD] Update base_user_role_company.pot
Oct 28, 2023
18632bd
[BOT] post-merge updates
OCA-git-bot Oct 28, 2023
6b702d9
Update translation files
weblate Oct 29, 2023
f93142f
Translated using Weblate (Spanish)
Ivorra78 Nov 8, 2023
c4fde12
Translated using Weblate (Italian)
mymage Jan 3, 2024
d2cf32b
base_user_role_company: allow same role in different companies
sebalix Feb 1, 2024
097e590
[BOT] post-merge updates
OCA-git-bot Feb 16, 2024
d8d648f
[IMP] base_user_role_company: black, isort, prettier
rconjour Feb 26, 2024
c962cbf
[MIG] base_user_role_company: Migration to 17.0
rconjour Feb 26, 2024
710b4cc
[UPD] Update base_user_role_company.pot
Mar 9, 2024
913b9a2
[BOT] post-merge updates
OCA-git-bot Mar 9, 2024
3146876
[IMP/FIX] base_user_role_company - re-add logic around multi active cids
jdidderen-noviat Apr 3, 2024
24c0d52
[BOT] post-merge updates
OCA-git-bot Apr 15, 2024
b7304f8
[FIX] base_user_role_company: Line too long
pedrobaeza May 2, 2024
d963ed0
[BOT] post-merge updates
OCA-git-bot May 2, 2024
d867a51
[IMP] base_user_role_company: pre-commit stuff
BertVGroenendael Oct 22, 2024
ca7da3f
[MIG] base_user_role_company: Migration to 18.0
BertVGroenendael Oct 23, 2024
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
135 changes: 135 additions & 0 deletions base_user_role_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
=====================
User roles by company
=====================

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

.. |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_company
: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_company
: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|

Enable User Roles depending on the Companies selected.

A company specific Role will only be enabled if it is set for **all**
the currently selected companies.

For example, if a user is "Sales Manager" only for Company A, it will
see that role enabled only if Company A is selected. If the user selects
Company A and Company B, then the "Sales Manager" role won't be enabled.

**Table of contents**

.. contents::
:local:

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

Roles are set on the User form.

The "Company" additional column allows to set a Role as only valid for
specific companies.

There is also a "Active Role" techincal field, only visible in developer
mode. It shows what roles are active, after applying the company
selection rules.

Usage
=====

Select the active companies from the web client widget, near the top
right corner. When doing so, the User's security Groups are recomputed,
based on the Roles.

When the user changes the company selection, only the groups available
to all active companies will be activated.

For example:

- A "SALES PERSON" and a "SALES MANAGER" roles are created.

- A user is assigned to the roles:

- "SALES PERSON", with no specific company assigned (meaning all)
- "SALES MANAGER" only to "My Company (Chicago)"

- When selecting active companies from the UI widget:

- If only "My Company (San Francisco)" is active, "SALES PERSON"
will be active.
- If only "My Company (Chicago)" is active, "SALES PERSON" and
"SALES MANAGER" will be active.
- If both "My Company (San Francisco)" and "My Company (Chicago)" is
active, "SALES PERSON" will be active.

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_company%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
-------

* Open Source Integrators

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

`Open Source Integrators <http://opensourceintegrators.com>`__

- Daniel Reis <dreis@opensourceintegrators.com>
- Chandresh Thakkar <cthakkr@opensourceintegrators.com>
- Urvisha Desai <udesai@opensourceintegrators.com>

`WeSolved <http://wesolved.com>`__

- Robin Conjour <rconjour@wesolved.com>

`Dynapps <http://dynapps.eu>`__

- Bert Van Groenendael <bert.vangroenendael@dynapps.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_company>`_ project on GitHub.

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

from . import controllers
from . import models
20 changes: 20 additions & 0 deletions base_user_role_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "User roles by company",
"version": "18.0.1.0.0",
"category": "Tools",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/server-backend",
"depends": ["base_user_role"],
"data": [
"views/role.xml",
"views/user.xml",
],
"installable": True,
"auto_install": True,
"maintainer": "dreispt",
"development_status": "Beta",
}
1 change: 1 addition & 0 deletions base_user_role_company/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
16 changes: 16 additions & 0 deletions base_user_role_company/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2022 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import http

from odoo.addons.web.controllers.home import Home


class HomeExtended(Home):
@http.route()
def web_load_menus(self, unique):
response = super().web_load_menus(unique)

Check warning on line 12 in base_user_role_company/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

base_user_role_company/controllers/main.py#L12

Added line #L12 was not covered by tests
# On logout & re-login we could see wrong menus being rendered
# To avoid this, menu http cache must be disabled
response.headers.remove("Cache-Control")
return response
58 changes: 58 additions & 0 deletions base_user_role_company/i18n/base_user_role_company.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_user_role_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \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: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__allowed_company_ids
msgid "Companies"
msgstr ""

#. module: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__company_id
msgid "Company"
msgstr ""

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_ir_http
msgid "HTTP Routing"
msgstr ""

#. module: base_user_role_company
#: model:ir.model.fields,help:base_user_role_company.field_res_users_role_line__company_id
msgid ""
"If set, this role only applies when this is the main company selected. "
"Otherwise it applies to all companies."
msgstr ""

#. module: base_user_role_company
#: model:ir.model.constraint,message:base_user_role_company.constraint_res_users_role_line_user_role_uniq
msgid "Roles can be assigned to a user only once at a time"
msgstr ""

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users
msgid "User"
msgstr ""

#. module: base_user_role_company
#. odoo-python
#: code:addons/base_user_role_company/models/role.py:0
#, python-format
msgid "User \"%(user)s\" does not have access to the company \"%(company)s\""
msgstr ""

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users_role_line
msgid "Users associated to a role"
msgstr ""
67 changes: 67 additions & 0 deletions base_user_role_company/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_user_role_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-08 14:36+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__allowed_company_ids
msgid "Companies"
msgstr "Compañías"

#. module: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__company_id
msgid "Company"
msgstr "Compañía"

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_ir_http
msgid "HTTP Routing"
msgstr "Enrutamiento HTTP"

#. module: base_user_role_company
#: model:ir.model.fields,help:base_user_role_company.field_res_users_role_line__company_id
msgid ""
"If set, this role only applies when this is the main company selected. "
"Otherwise it applies to all companies."
msgstr ""
"Si se establece, este rol sólo se aplica cuando ésta es la compañía "
"principal seleccionada. De lo contrario, se aplica a todas las compañías."

#. module: base_user_role_company
#: model:ir.model.constraint,message:base_user_role_company.constraint_res_users_role_line_user_role_uniq
msgid "Roles can be assigned to a user only once at a time"
msgstr "Las funciones sólo pueden asignarse a un usuario una vez cada vez"

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users
msgid "User"
msgstr "Usuario"

#. module: base_user_role_company
#. odoo-python
#: code:addons/base_user_role_company/models/role.py:0
#, python-format
msgid "User \"%(user)s\" does not have access to the company \"%(company)s\""
msgstr "El usuario \"%(user)s\" no tiene acceso a la empresa \"%(company)s\""

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users_role_line
msgid "Users associated to a role"
msgstr "Usuarios asociados a un papel"

#, python-format
#~ msgid "User \"{}\" does not have access to the company \"{}\""
#~ msgstr "Usuario \"{}\" no tiene acceso a la compañía \"{}\""
82 changes: 82 additions & 0 deletions base_user_role_company/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_user_role_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-01-03 14:33+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__allowed_company_ids
msgid "Companies"
msgstr "Aziende"

#. module: base_user_role_company
#: model:ir.model.fields,field_description:base_user_role_company.field_res_users_role_line__company_id
msgid "Company"
msgstr "Azienda"

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_ir_http
msgid "HTTP Routing"
msgstr "Instradamento HTTP"

#. module: base_user_role_company
#: model:ir.model.fields,help:base_user_role_company.field_res_users_role_line__company_id
msgid ""
"If set, this role only applies when this is the main company selected. "
"Otherwise it applies to all companies."
msgstr ""
"Se impostato, questo ruolo si applica solo quando questa è l'azienda "
"principale selezionata. Altrimenti vale per tutte le aziende."

#. module: base_user_role_company
#: model:ir.model.constraint,message:base_user_role_company.constraint_res_users_role_line_user_role_uniq
msgid "Roles can be assigned to a user only once at a time"
msgstr "I ruoli possono essere assegnati all'utente solo uno alla volta"

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users
msgid "User"
msgstr "Utente"

#. module: base_user_role_company
#. odoo-python
#: code:addons/base_user_role_company/models/role.py:0
#, python-format
msgid "User \"%(user)s\" does not have access to the company \"%(company)s\""
msgstr "L'utente \"%(user)s\" non ha accesso all'azienda \"%(company)s\""

#. module: base_user_role_company
#: model:ir.model,name:base_user_role_company.model_res_users_role_line
msgid "Users associated to a role"
msgstr "Utenti associati al ruolo"

#, python-format
#~ msgid "User \"{}\" does not have access to the company \"{}\""
#~ msgstr "L'utente \"{}\" non ha l'accesso all'azienda \"{}\""

#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"

#~ msgid "Users"
#~ msgstr "Utenti"

#~ msgid "Active Role"
#~ msgstr "Ruolo attivo"
Loading
Loading