Skip to content

Commit 71a61f1

Browse files
committed
Merge PR #966 into 18.0
Signed-off-by pedrobaeza
2 parents 28e8371 + 426d09c commit 71a61f1

15 files changed

Lines changed: 759 additions & 0 deletions
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
===============
2+
Extra user type
3+
===============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:7bed5b4567c42e48ecb669672405f584357383f4338c07303e24397807485504
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-auth/tree/18.0/base_group_subcontractor
21+
:alt: OCA/server-auth
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-base_group_subcontractor
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-auth&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a new isolated user type group called "Subcontractors",
32+
that simulates to be an internal user, giving access to the backend, but
33+
only granting the minimum permissions for the web client to work, and
34+
only exposing the Discuss menu.
35+
36+
The rest of the needed permissions for that subcontractors should be
37+
given in extra customizations.
38+
39+
**Table of contents**
40+
41+
.. contents::
42+
:local:
43+
44+
Use Cases / Context
45+
===================
46+
47+
A usual need inside a company using Odoo is to have external people
48+
(subcontractors) that need to access Odoo to do certain operations that
49+
are not allowed (or they are not comfortable) in the portal, but giving
50+
them an internal system user is too much, as there some visible
51+
information (like contacts or calendar events) that shouldn't be shown
52+
by these users, even by legal reasons (GDPR, etc).
53+
54+
Known issues / Roadmap
55+
======================
56+
57+
- Any extra installed module that performs operations on the web client
58+
(example: base_tier_validation), will require glue modules that adds
59+
the permissions for the corresponding models.
60+
61+
Bug Tracker
62+
===========
63+
64+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
65+
In case of trouble, please check there if your issue has already been reported.
66+
If you spotted it first, help us to smash it by providing a detailed and welcomed
67+
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20base_group_subcontractor%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
69+
Do not contact contributors directly about support or help with technical issues.
70+
71+
Credits
72+
=======
73+
74+
Authors
75+
-------
76+
77+
* Tecnativa
78+
79+
Maintainers
80+
-----------
81+
82+
This module is maintained by the OCA.
83+
84+
.. image:: https://odoo-community.org/logo.png
85+
:alt: Odoo Community Association
86+
:target: https://odoo-community.org
87+
88+
OCA, or the Odoo Community Association, is a nonprofit organization whose
89+
mission is to support the collaborative development of Odoo features and
90+
promote its widespread use.
91+
92+
.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px
93+
:target: https://github.com/pedrobaeza
94+
:alt: pedrobaeza
95+
96+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
97+
98+
|maintainer-pedrobaeza|
99+
100+
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/18.0/base_group_subcontractor>`_ project on GitHub.
101+
102+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2026 Tecnativa - Pedro M. Baeza
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
{
4+
"name": "Extra user type",
5+
"summary": "Extra user type group for restricted access to backend",
6+
"version": "18.0.1.0.0",
7+
"development_status": "Beta",
8+
"category": "Tools",
9+
"website": "https://github.com/OCA/server-auth",
10+
"author": "Tecnativa, Odoo Community Association (OCA)",
11+
"maintainers": ["pedrobaeza"],
12+
"license": "AGPL-3",
13+
"depends": [
14+
"mail",
15+
"web_editor",
16+
],
17+
"demo": [
18+
"demo/res_users_demo.xml",
19+
],
20+
"data": [
21+
"security/base_group_subcontractor_security.xml",
22+
"security/ir.model.access.csv",
23+
"data/ir_ui_menu_data.xml",
24+
],
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<odoo>
2+
<record id="mail.menu_root_discuss" model="ir.ui.menu">
3+
<field
4+
name="groups_id"
5+
eval="[Command.link(ref('base_group_subcontractor.group_subcontractor'))]"
6+
/>
7+
</record>
8+
</odoo>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<record id="partner_subcontractor" model="res.partner">
4+
<field name="name">John Smith</field>
5+
<field name="company_id" ref="base.main_company" />
6+
<field name="street">C/ Smith, 17</field>
7+
<field name="city">Alicante</field>
8+
<field name="state_id" ref="base.state_es_a" />
9+
<field name="zip">03008</field>
10+
<field name="country_id" ref="base.es" />
11+
<field name="tz">Europe/Madrid</field>
12+
<field name="email">john.smith@example.com</field>
13+
</record>
14+
<record
15+
id="user_subcontractor"
16+
model="res.users"
17+
context="{'no_reset_password': True}"
18+
>
19+
<field name="partner_id" ref="partner_subcontractor" />
20+
<field name="login">subcontractor</field>
21+
<field name="password">subcontractor</field>
22+
<field name="signature" type="html">
23+
<span>-- <br />+Mr Subcontractor</span>
24+
</field>
25+
<field name="company_id" ref="base.main_company" />
26+
<field name="groups_id" eval="[Command.clear()]" />
27+
<!-- Avoid auto-including this user in any default group -->
28+
<field
29+
name="image_1920"
30+
type="base64"
31+
file="base_group_subcontractor/static/img/user_subcontractor-image.png"
32+
/>
33+
</record>
34+
<!-- oca-hooks:disable=xml-duplicate-record-id -->
35+
<record id="partner_subcontractor" model="res.partner">
36+
<field name="user_id" ref="user_subcontractor" />
37+
</record>
38+
<!-- Add the subcontractor user to the subcontractor group -->
39+
<record id="group_subcontractor" model="res.groups">
40+
<field name="users" eval="[Command.link(ref('user_subcontractor'))]" />
41+
</record>
42+
</odoo>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_users
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2026 Tecnativa - Pedro M. Baeza
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo import api, models
4+
5+
6+
class ResUsers(models.Model):
7+
_inherit = "res.users"
8+
9+
def _compute_share(self):
10+
# Consider as non shared those users of subcontractor group
11+
res = super()._compute_share()
12+
user_group_id = self.env["ir.model.data"]._xmlid_to_res_id(
13+
"base_group_subcontractor.group_subcontractor"
14+
)
15+
self.filtered_domain([("groups_id", "in", [user_group_id])]).share = False
16+
return res
17+
18+
@api.readonly
19+
def has_group(self, group_ext_id: str) -> bool:
20+
# trick this method to test also the belonging to the new subcontractor group
21+
alt_value = False
22+
if group_ext_id == "base.group_user":
23+
alt_value = super().has_group(
24+
"base_group_subcontractor.group_subcontractor"
25+
)
26+
return alt_value or super().has_group(group_ext_id)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A usual need inside a company using Odoo is to have external people (subcontractors)
2+
that need to access Odoo to do certain operations that are not allowed (or they are not
3+
comfortable) in the portal, but giving them an internal system user is too much, as
4+
there some visible information (like contacts or calendar events) that shouldn't be
5+
shown by these users, even by legal reasons (GDPR, etc).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This module adds a new isolated user type group called "Subcontractors", that simulates
2+
to be an internal user, giving access to the backend, but only granting the minimum
3+
permissions for the web client to work, and only exposing the Discuss menu.
4+
5+
The rest of the needed permissions for that subcontractors should be given in extra
6+
customizations.

0 commit comments

Comments
 (0)