Skip to content

Commit a6bec93

Browse files
committed
Merge PR #373 into 18.0
Signed-off-by bguillot
2 parents 7b2c6e6 + 9de4448 commit a6bec93

28 files changed

+1398
-0
lines changed

base_group_backend/README.rst

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
=============
2+
Group backend
3+
=============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:94aa0fca553bd76339b493d1406d1fad68c724126ff95cfecea7d30228bd6b90
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Alpha
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-backend/tree/18.0/base_group_backend
21+
:alt: OCA/server-backend
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-backend-18-0/server-backend-18-0-base_group_backend
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds two "Backend User" groups (``group_backend`` and
32+
``group_backend_ui_users``) with restricted access to odoo backend only
33+
(``/web``), with less and more controlled access than the native
34+
"Internal User" group.
35+
36+
The problem with the "Internal User" group (``base.group_user``) is
37+
that it can be used by any new module added to your project, so you
38+
don't control clearly this group's accesses.
39+
40+
The UI access is provided only for ``group_backend_ui_users`` :
41+
42+
- minimal default access rules to access the user's own data:
43+
44+
- users and partners
45+
- mail activity, notification and channel
46+
- presence
47+
48+
- minimal default menu to restrict the available ones:
49+
50+
- notification
51+
- activities
52+
53+
Here is an example where a user from ``group_backend_ui_users`` can only
54+
access and use the Dummy App. No other application is available to this
55+
user (you may define your own application instead of the Dummy one).
56+
57+
|image1|
58+
59+
We suggest to use this module with its companion ``base_user_role``.
60+
61+
Limitations
62+
-----------
63+
64+
At the time of writing, Odoo uses ``user.share == False`` and
65+
``user.has_group("base.group_user") == True`` to give the backend access
66+
to ``user``.
67+
68+
So technically, the module does 2 things :
69+
70+
- It sets the ``share`` parameter to ``False`` for ``group_backend``
71+
users.
72+
- It hijacks the ``has_group`` method of res.users by returning
73+
``True`` for ``group_backend`` users when the requested group is
74+
``base.group_user``
75+
76+
This avoids to write a lot of overwrite in different controllers from
77+
different modules ('portal', 'web', 'base', 'website') with hard coded
78+
statements that check if user is part of the ``base.group_user`` or
79+
``share == False`` group.
80+
81+
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-backend/18.0/base_group_backend/static/description/dummy_app.png
82+
83+
.. IMPORTANT::
84+
This is an alpha version, the data model and design can change at any time without warning.
85+
Only for development or testing purpose, do not use in production.
86+
`More details on development status <https://odoo-community.org/page/development-status>`_
87+
88+
**Table of contents**
89+
90+
.. contents::
91+
:local:
92+
93+
Configuration
94+
=============
95+
96+
To allow a user from the ``group_backend_ui_users`` group to interact
97+
with a specific model you can either add an access rules to this model
98+
for ``group_backend_ui_users`` or you can add ``group_backend_ui_users``
99+
to the ``implied_ids`` of a new specific group.
100+
101+
The Backend groups are from the "User types" category
102+
(``base.module_category_user_type``), the same category as "Internal
103+
User" (``base.group_user``), "Portal" (``base.group_portal``) or Public
104+
(``base.group_public``). Be aware that a user can only belongs to **one
105+
group of this category**.
106+
107+
Usage
108+
=====
109+
110+
To use this module, add a user to the group "Backend user" or "Backend
111+
UI user" through the user's form page.
112+
113+
|image1|
114+
115+
If you created a specific group with ``group_backend`` or
116+
``group_backend_ui_users`` in its ``implied_ids``, you need to go
117+
through the group's form page in order to add the user to this specific
118+
group, because it won't be displayed on the user's form page (a specific
119+
group with its own category is displayed on user's form page only if the
120+
group inherits the "Internal user" group).
121+
122+
This module also **restricts the root menus** displayed to Backend
123+
users, so be sure to explicitly add your Backend group to all the
124+
necessary root menus for these users.
125+
126+
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-backend/18.0/base_group_backend/static/description/backend_ui.png
127+
128+
Bug Tracker
129+
===========
130+
131+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_.
132+
In case of trouble, please check there if your issue has already been reported.
133+
If you spotted it first, help us to smash it by providing a detailed and welcomed
134+
`feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_group_backend%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
135+
136+
Do not contact contributors directly about support or help with technical issues.
137+
138+
Credits
139+
=======
140+
141+
Authors
142+
-------
143+
144+
* Pierre Verkest
145+
146+
Contributors
147+
------------
148+
149+
- Pierre Verkest <pierreverkest84@gmail.com>
150+
- François Poizat <francois.poizat@gmail.com>
151+
152+
Do not contact contributors directly about support or help with
153+
technical issues.
154+
155+
Maintainers
156+
-----------
157+
158+
This module is maintained by the OCA.
159+
160+
.. image:: https://odoo-community.org/logo.png
161+
:alt: Odoo Community Association
162+
:target: https://odoo-community.org
163+
164+
OCA, or the Odoo Community Association, is a nonprofit organization whose
165+
mission is to support the collaborative development of Odoo features and
166+
promote its widespread use.
167+
168+
.. |maintainer-FranzPoize| image:: https://github.com/FranzPoize.png?size=40px
169+
:target: https://github.com/FranzPoize
170+
:alt: FranzPoize
171+
.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px
172+
:target: https://github.com/bealdav
173+
:alt: bealdav
174+
175+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
176+
177+
|maintainer-FranzPoize| |maintainer-bealdav|
178+
179+
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/18.0/base_group_backend>`_ project on GitHub.
180+
181+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

base_group_backend/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import demo

base_group_backend/__manifest__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021 Pierre Verkest <pierreverkest84@gmail.com>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
{
4+
"name": "Group backend",
5+
"version": "18.0.1.0.0",
6+
"development_status": "Alpha",
7+
"category": "Tools",
8+
"author": "Pierre Verkest, Odoo Community Association (OCA)",
9+
"license": "LGPL-3",
10+
"website": "https://github.com/OCA/server-backend",
11+
"depends": [
12+
"base",
13+
"mail",
14+
"calendar",
15+
],
16+
"maintainers": ["FranzPoize", "bealdav"],
17+
"demo": [
18+
"demo/test-model.xml",
19+
"demo/ir.model.access.csv",
20+
"demo/backend_dummy_model.xml",
21+
"demo/res_partners.xml",
22+
"demo/res_users.xml",
23+
],
24+
"data": [
25+
"data/res_groups.xml",
26+
"security/ir.model.access.csv",
27+
],
28+
"installable": True,
29+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<odoo>
2+
<record model="res.groups" id="base_group_backend">
3+
<field name="name">Backend user</field>
4+
<field name="category_id" ref="base.module_category_user_type" />
5+
<field name="comment">
6+
This group is used to gives user backend access.
7+
8+
While users in `base.group_user` gets a lot of default access
9+
which makes hard to define properly records/rules/menu access.
10+
11+
So for maintainability you shouldn't linked any access right, rules,
12+
menu, and so on to this group directly.
13+
14+
The only intent of this groups is to be able to get a session
15+
to Odoo backend (`/web`).
16+
</field>
17+
</record>
18+
19+
<record model="res.groups" id="group_backend_ui_users">
20+
<field name="name">Backend UI user</field>
21+
<field name="category_id" ref="base.module_category_user_type" />
22+
<field name="comment">
23+
This group is used to gives user basic ui access.
24+
</field>
25+
<field
26+
name="rule_groups"
27+
eval="[
28+
(6, 0,[
29+
ref('base.ir_default_user_rule'),
30+
ref('base.ir_filters_delete_own_rule'),
31+
ref('base.ir_filters_employee_rule'),
32+
ref('base.res_company_rule_employee'),
33+
ref('mail.ir_rule_mail_notifications_group_user'),
34+
ref('mail.ir_rule_discuss_channel_all'),
35+
ref('mail.ir_rule_discuss_channel_member_is_self_all'),
36+
ref('mail.ir_rule_discuss_channel_member_read_all'),
37+
ref('mail.mail_activity_rule_user'),
38+
]),
39+
]"
40+
/>
41+
</record>
42+
</odoo>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from odoo.tools import config
2+
3+
if not config["without_demo"]:
4+
from . import backend_dummy_model
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import fields, models
2+
3+
4+
class BackendDummyModel(models.Model):
5+
_name = "backend.dummy.model"
6+
_description = "Backend Dummy Model demo"
7+
8+
my_value = fields.Char(name="Value", required=True)
9+
my_other_value = fields.Char(name="Other value", required=True)
10+
date_start = fields.Datetime(
11+
name="Date start", required=True, default=fields.Datetime.now
12+
)
13+
date_stop = fields.Datetime(
14+
name="Date stop", required=True, default=fields.Datetime.now
15+
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="backend_dummy_model_tree_view" model="ir.ui.view">
4+
<field name="name">Backend dummy list view</field>
5+
<field name="model">backend.dummy.model</field>
6+
<field name="arch" type="xml">
7+
<list create="false" delete="false">
8+
<field name="my_value" />
9+
<field name="my_other_value" groups="base.group_user" />
10+
</list>
11+
</field>
12+
</record>
13+
14+
<record id="action_dummy_list" model="ir.actions.act_window">
15+
<field name="name">Dummies</field>
16+
<field name="type">ir.actions.act_window</field>
17+
<field name="res_model">backend.dummy.model</field>
18+
<field name="view_mode">list,form,kanban,calendar,pivot,graph,activity</field>
19+
<field name="view_id" ref="backend_dummy_model_tree_view" />
20+
</record>
21+
22+
<menuitem
23+
id="menu_dummy_root"
24+
name="Dummy"
25+
sequence="100"
26+
groups="group_backend_ui_users,base.group_user"
27+
/>
28+
<menuitem
29+
id="menu_dummy_menu"
30+
name="Dummy"
31+
sequence="10"
32+
groups="group_backend_ui_users,base.group_user"
33+
parent="menu_dummy_root"
34+
/>
35+
<menuitem
36+
id="menu_dummy_list"
37+
name="Dummy list"
38+
sequence="100"
39+
groups="group_backend_ui_users,base.group_user"
40+
parent="menu_dummy_root"
41+
action="action_dummy_list"
42+
/>
43+
44+
<menuitem id="menu_root_no_group" name="No Group" sequence="100" />
45+
<menuitem
46+
id="menu_dummy_list_no_group"
47+
name="Dummy list No group"
48+
sequence="100"
49+
groups="group_backend_ui_users,base.group_user"
50+
parent="menu_root_no_group"
51+
action="action_dummy_list"
52+
/>
53+
</odoo>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2+
"backend_dummy_models","backend dummy.model","model_backend_dummy_model",group_backend_ui_users,1,0,0,0
3+
"backend_dummy_models_user_grp","backend dummy.model user grp","model_backend_dummy_model",base.group_user,1,0,0,0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="demo_partner" model="res.partner">
4+
<field name="name">Demo partner backend</field>
5+
</record>
6+
<record id="demo_partner1" model="res.partner">
7+
<field name="name">Demo partner backend 1</field>
8+
</record>
9+
<record id="demo_partner2" model="res.partner">
10+
<field name="name">Demo partner backend 2</field>
11+
</record>
12+
</odoo>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="user_demo" model="res.users">
4+
<field name="login">demo backend user</field>
5+
<field name="groups_id" eval="[Command.set([ref('base.group_user')])]" />
6+
<field name="partner_id" ref="base_group_backend.demo_partner" />
7+
</record>
8+
<record id="user_demo_external" model="res.users">
9+
<field name="login">demo backend user 1</field>
10+
<field name="groups_id" eval="[Command.set([ref('base.group_portal')])]" />
11+
<field name="partner_id" ref="base_group_backend.demo_partner1" />
12+
</record>
13+
<record id="user_demo_external_with_ui" model="res.users">
14+
<field name="login">demo backend user 2</field>
15+
<field
16+
name="groups_id"
17+
eval="[Command.set([ref('base_group_backend.group_backend_ui_users')])]"
18+
/>
19+
<field name="partner_id" ref="base_group_backend.demo_partner2" />
20+
</record>
21+
</odoo>

0 commit comments

Comments
 (0)