Skip to content

Commit 2b43e2a

Browse files
[IMP] operating_unit: Linked users button and bulk sync action
1 parent dd2e0c5 commit 2b43e2a

8 files changed

Lines changed: 123 additions & 37 deletions

File tree

operating_unit/README.rst

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
==============
62
Operating Unit
73
==============
@@ -17,7 +13,7 @@ Operating Unit
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2218
:alt: License: LGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
@@ -32,14 +28,24 @@ Operating Unit
3228

3329
|badge1| |badge2| |badge3| |badge4| |badge5|
3430

35-
An operating unit (OU) is an organizational entity part of a company,
36-
with separate management ownership. Management by OU is aimed to
37-
introduce the following features:
31+
AnThis module maintains the administrative units (Operating Units) to
32+
which resources can be associated. An Operating Unit (OU) is a child of
33+
a Company.
34+
35+
**Improvements in this version:**
36+
37+
- Added a Stat Button on Operating Units to easily view and manage
38+
linked users. with separate management ownership. Management by OU is
39+
aimed to introduce the following features:
3840

3941
- Data partitioning from other OU.
42+
4043
- Own sequencing schemes.
44+
4145
- User access administration for data processing and reporting.
46+
4247
- Product and customer independence of OU.
48+
4349
- OU specific P&L and Balance sheet.
4450

4551
**Table of contents**
@@ -62,6 +68,12 @@ Usage
6268
This module defines the operating unit entity and the user's security
6369
rules. Other modules extend the standard Odoo apps with the OU.
6470

71+
**Stat Button for Linked Users**
72+
73+
On the Operating Unit form, a Stat Button "Users" is available to
74+
quickly access all users linked to that unit, including managers of the
75+
unit.
76+
6577
Known issues / Roadmap
6678
======================
6779

@@ -95,6 +107,9 @@ Contributors
95107
- Andrea Stirpe <a.stirpe@onestein.nl>
96108
- Ooops, Ashish Hirpara <ashish.hirapara1995@gmail.com>
97109
- Daniel Lagin <daniel.lagin@braintec.com>
110+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
111+
112+
- Bhavesh Heliconia
98113

99114
Maintainers
100115
-----------

operating_unit/models/operating_unit.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,33 @@ def create(self, vals_list):
5656
def write(self, vals):
5757
self.env.registry.clear_cache()
5858
return super().write(vals)
59+
60+
def button_open_linked_users(self) -> dict:
61+
self.ensure_one()
62+
action_vals = {
63+
"name": self.env._("Users"),
64+
"type": "ir.actions.act_window",
65+
"res_model": "res.users",
66+
"view_mode": "list,form",
67+
"context": {"create": False, "edit": False, "delete": False},
68+
}
69+
70+
group = self.env.ref(
71+
"operating_unit.group_manager_operating_unit",
72+
raise_if_not_found=False,
73+
)
74+
user_recs = self.user_ids
75+
if group:
76+
user_recs |= group.users
77+
if not user_recs:
78+
return action_vals
79+
if len(user_recs) == 1:
80+
action_vals.update(
81+
{
82+
"view_mode": "form",
83+
"res_id": user_recs.id,
84+
}
85+
)
86+
else:
87+
action_vals["domain"] = [("id", "in", user_recs.ids)]
88+
return action_vals

operating_unit/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
- Andrea Stirpe \<<a.stirpe@onestein.nl>\>
55
- Ooops, Ashish Hirpara \<<ashish.hirapara1995@gmail.com>\>
66
- Daniel Lagin \<<daniel.lagin@braintec.com>\>
7+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
8+
- Bhavesh Heliconia

operating_unit/readme/DESCRIPTION.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
An operating unit (OU) is an organizational entity part of a company,
1+
AnThis module maintains the administrative units (Operating Units) to which
2+
resources can be associated. An Operating Unit (OU) is a child of a
3+
Company.
4+
5+
**Improvements in this version:**
6+
- Added a Stat Button on Operating Units to easily view and manage linked users.
27
with separate management ownership. Management by OU is aimed to
38
introduce the following features:
49

operating_unit/readme/USAGE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
This module defines the operating unit entity and the user's security
22
rules. Other modules extend the standard Odoo apps with the OU.
3+
4+
**Stat Button for Linked Users**
5+
6+
On the Operating Unit form, a Stat Button "Users" is available to quickly access all users linked to that unit, including managers of the unit.
7+

operating_unit/static/description/index.html

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Operating Unit</title>
77
<style type="text/css">
88

99
/*
@@ -360,25 +360,24 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="operating-unit">
364+
<h1 class="title">Operating Unit</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="operating-unit">
370-
<h1>Operating Unit</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:ca21463eb1db9a29de1b428d7c782cf4c92fa40ded17fd42d07b55e41cd3697f
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/18.0/operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378-
<p>An operating unit (OU) is an organizational entity part of a company,
379-
with separate management ownership. Management by OU is aimed to
380-
introduce the following features:</p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/18.0/operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373+
<p>AnThis module maintains the administrative units (Operating Units) to
374+
which resources can be associated. An Operating Unit (OU) is a child of
375+
a Company.</p>
376+
<p><strong>Improvements in this version:</strong></p>
381377
<ul class="simple">
378+
<li>Added a Stat Button on Operating Units to easily view and manage
379+
linked users. with separate management ownership. Management by OU is
380+
aimed to introduce the following features:</li>
382381
<li>Data partitioning from other OU.</li>
383382
<li>Own sequencing schemes.</li>
384383
<li>User access administration for data processing and reporting.</li>
@@ -401,7 +400,7 @@ <h1>Operating Unit</h1>
401400
</ul>
402401
</div>
403402
<div class="section" id="configuration">
404-
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
403+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
405404
<p>To configure this module, you need to:</p>
406405
<ul class="simple">
407406
<li>Assign <em>Multi Operating Unit</em> group to user.</li>
@@ -410,43 +409,51 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
410409
</ul>
411410
</div>
412411
<div class="section" id="usage">
413-
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
412+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
414413
<p>This module defines the operating unit entity and the user’s security
415414
rules. Other modules extend the standard Odoo apps with the OU.</p>
415+
<p><strong>Stat Button for Linked Users</strong></p>
416+
<p>On the Operating Unit form, a Stat Button “Users” is available to
417+
quickly access all users linked to that unit, including managers of the
418+
unit.</p>
416419
</div>
417420
<div class="section" id="known-issues-roadmap">
418-
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
421+
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
419422
</div>
420423
<div class="section" id="bug-tracker">
421-
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
424+
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
422425
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/operating-unit/issues">GitHub Issues</a>.
423426
In case of trouble, please check there if your issue has already been reported.
424427
If you spotted it first, help us to smash it by providing a detailed and welcomed
425428
<a class="reference external" href="https://github.com/OCA/operating-unit/issues/new?body=module:%20operating_unit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
426429
<p>Do not contact contributors directly about support or help with technical issues.</p>
427430
</div>
428431
<div class="section" id="credits">
429-
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
432+
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
430433
<div class="section" id="authors">
431-
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
434+
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
432435
<ul class="simple">
433436
<li>ForgeFlow</li>
434437
<li>Serpent Consulting Services Pvt. Ltd.</li>
435438
</ul>
436439
</div>
437440
<div class="section" id="contributors">
438-
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
441+
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
439442
<ul class="simple">
440443
<li>ForgeFlow &lt;<a class="reference external" href="mailto:contact&#64;forgeflow.com">contact&#64;forgeflow.com</a>&gt;</li>
441444
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
442445
<li>Jarsa Sistemas &lt;<a class="reference external" href="mailto:info&#64;jarsa.com.mx">info&#64;jarsa.com.mx</a>&gt;</li>
443446
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
444447
<li>Ooops, Ashish Hirpara &lt;<a class="reference external" href="mailto:ashish.hirapara1995&#64;gmail.com">ashish.hirapara1995&#64;gmail.com</a>&gt;</li>
445448
<li>Daniel Lagin &lt;<a class="reference external" href="mailto:daniel.lagin&#64;braintec.com">daniel.lagin&#64;braintec.com</a>&gt;</li>
449+
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
450+
<li>Bhavesh Heliconia</li>
451+
</ul>
452+
</li>
446453
</ul>
447454
</div>
448455
<div class="section" id="maintainers">
449-
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
456+
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
450457
<p>This module is maintained by the OCA.</p>
451458
<a class="reference external image-reference" href="https://odoo-community.org">
452459
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -459,6 +466,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
459466
</div>
460467
</div>
461468
</div>
462-
</div>
463469
</body>
464470
</html>

operating_unit/tests/test_operating_unit.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,12 @@ def test_create_multi_operating_unit(self):
140140
self.assertEqual(res[0].user_ids, self.user1)
141141
self.assertEqual(res[1].user_ids, self.user1)
142142
self.assertEqual(res[2].user_ids, self.user1)
143+
144+
def test_button_open_linked_users(self):
145+
"""Test the Stat Button that opens linked users."""
146+
# Add another user to ou1
147+
self._create_user("user_extra", self.grp_ou_multi, self.company, [self.ou1])
148+
action = self.ou1.button_open_linked_users()
149+
self.assertEqual(action["res_model"], "res.users")
150+
self.assertEqual(action.get("view_mode"), "list,form")
151+
self.assertIn("domain", action)

operating_unit/view/operating_unit_view.xml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@
55
<field name="model">operating.unit</field>
66
<field name="arch" type="xml">
77
<form string="Operating Unit">
8-
<group name="main_group">
9-
<field name="name" />
10-
<field name="code" />
11-
<field name="active" />
12-
<field name="partner_id" />
13-
<field name="company_id" groups="base.group_multi_company" />
14-
</group>
8+
<sheet>
9+
<div class="oe_button_box" name="button_box">
10+
<button
11+
name="button_open_linked_users"
12+
type="object"
13+
class="oe_stat_button"
14+
icon="fa-users"
15+
>
16+
<div class="o_stat_info">
17+
<span class="o_stat_text">Users</span>
18+
</div>
19+
</button>
20+
</div>
21+
<group name="main_group">
22+
<field name="name" />
23+
<field name="code" />
24+
<field name="active" />
25+
<field name="partner_id" />
26+
<field name="company_id" groups="base.group_multi_company" />
27+
</group>
28+
</sheet>
1529
</form>
1630
</field>
1731
</record>

0 commit comments

Comments
 (0)