Skip to content

Commit

Permalink
REF rename group_backend to base_group_backend
Browse files Browse the repository at this point in the history
  • Loading branch information
petrus-v authored and bealdav committed Mar 3, 2023
1 parent d9ca805 commit 2a656ab
Show file tree
Hide file tree
Showing 19 changed files with 544 additions and 67 deletions.
32 changes: 18 additions & 14 deletions group_backend/README.rst → base_group_backend/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Group backend
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/14.0/group_backend
:target: https://github.com/OCA/server-backend/tree/16.0/base_group_backend
: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-14-0/server-backend-14-0-group_backend
:target: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_group_backend
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/253/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/server-backend&target_branch=16.0
:alt: Try me on Runboat

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

This module was written to extend the standard functionality regarding users
and groups management by adding a new `Backend user` group that only gives access
Expand All @@ -39,8 +39,7 @@ to odoo backend (`/web`):
The problem with the `Internal user` is when you want to gives access to the
backend to a really thin part of your business to some users, it's quite hard
to properly maintain those roles over the project life, a lot of models use
that group (`base.group_user`) by default which makes hard
to maintain.
that group (`base.group_user`) by default which makes hard to maintains.

So that helps creating well-defined user groups with more controls.

Expand All @@ -53,7 +52,7 @@ Limitations
At the time of writing, Odoo uses `has_group("base.group_user")` to give the
backend access.
This module is only overloading that method to try if user is in the
`group_backend.group_backend` group (in case of `base.group_user`
`base_group_backend.group_backend` group (in case of `base.group_user`
is requested and return `False`) to let access to the odoo backend.

This avoids to write a lot of overwrite in different controllers from
Expand Down Expand Up @@ -81,7 +80,7 @@ using `implied_ids` if you really want to link it.

Be aware users can only belong to one group from the user type category
(`base.module_category_user_type`). So your other groups can't inherit both
internal users and backend users.
internal users and backend users.

Usage
=====
Expand All @@ -94,14 +93,13 @@ You get a users that is only able to access to the Odoo backend which you
can attach other groups that not implies other kind of users (`portal`,
`internal users`)


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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20group_backend%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_group_backend%0Aversion:%2016.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.

Expand Down Expand Up @@ -133,8 +131,14 @@ 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.

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
.. |maintainer-oca| image:: https://github.com/oca.png?size=40px
:target: https://github.com/oca
:alt: oca

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-oca|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Group backend",
"version": "14.0.2.1.1",
"version": "16.0.1.0.0",
"category": "Tools",
"author": "Pierre Verkest, Odoo Community Association (OCA)",
"license": "AGPL-3",
"license": "LGPL-3",
"maintainers": ["oca"],
"website": "https://github.com/OCA/server-backend",
"depends": ["base"],
Expand Down
18 changes: 18 additions & 0 deletions base_group_backend/data/res-groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<odoo>
<record model="res.groups" id="group_backend">
<field name="name">Backend user</field>
<field name="category_id" ref="base.module_category_user_type" />
<field name="comment">
This group is used to gives user backend access.

While users in `base.group_user` gets a lot of default access
which makes hard to define properly records/rules/menu access.

So for maintainability you shouldn't linked any access right, rules,
menu, and so on to this group directly.

The only intent of this groups is to be able to get a session
to Odoo backend (`/web`).
</field>
</record>
</odoo>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Users(models.Model):
@api.model
def has_group(self, group_ext_id):
"""While ensuring a user is part of `base.group_user` this code will
try if user is in the `group_backend.group_backend` group to let access
try if user is in the `base_group_backend.group_backend` group to let access
to the odoo backend.
This code avoid to overwrite a lot of places in controllers from
Expand All @@ -21,12 +21,12 @@ def has_group(self, group_ext_id):
As far `base.group_user` have a lot of default permission this
makes hard to maintain proper access right according your business.
"""
res = super(Users, self).has_group(group_ext_id)
res = super().has_group(group_ext_id)
if not res and group_ext_id == "base.group_user":
has_group_backend = super(Users, self).has_group(
"group_backend.group_backend"
has_base_group_backend = super().has_group(
"base_group_backend.group_backend"
)
if has_group_backend:
if has_base_group_backend:
_logger.warning("Forcing has_group to return True for group_backend")
return has_group_backend
return has_base_group_backend
return res
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ using `implied_ids` if you really want to link it.

.. note::

Be aware users can only belongs to one group from the user type category
(`base.module_category_user_type`). So your group can't implied_ids to both
Be aware users can only belong to one group from the user type category
(`base.module_category_user_type`). So your other groups can't inherit both
internal users and backend users.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ to odoo backend (`/web`):
The problem with the `Internal user` is when you want to gives access to the
backend to a really thin part of your business to some users, it's quite hard
to properly maintain those roles over the project life, a lot of models use
that group (`base.group_user`) by default which makes hard
to maintains.
that group (`base.group_user`) by default which makes hard to maintains.

So that helps creating well-defined user groups with more controls.

Expand All @@ -23,13 +22,13 @@ We suggest to use this module with its compagnon `base_user_role`
Limitations
~~~~~~~~~~~

As the time of writing Odoo use `has_group("base.group_user")` to gives the
At the time of writing, Odoo uses `has_group("base.group_user")` to give the
backend access.
This module is only overloading that method to try if user is in the
`group_backend.group_backend` group (in case of `base.group_user`
`base_group_backend.group_backend` group (in case of `base.group_user`
is requested and return `False`) to let access to the odoo backend.

This avoid to overwrite a lot of overwrite in different controllers from
This avoids to write a lot of overwrite in different controllers from
different modules ('portal', 'web', 'base', 'website') with hard coded statements
that check if user is part of the `base.group_user` group.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To use this module, you need to:

#. Go to Configuration / Users / Users choose user and set the user type.
#. Go to Configuration / Users / Users, choose a user and set the user type.

You get a users that is only able to access to the Odoo backend which you
can attach other groups that not implies other kind of users (`portal`,
Expand Down
Loading

0 comments on commit 2a656ab

Please sign in to comment.