Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 23 additions & 8 deletions operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==============
Operating Unit
==============
Expand All @@ -17,7 +13,7 @@ Operating Unit
.. |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/license-LGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
Expand All @@ -32,14 +28,24 @@ Operating Unit

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

An operating unit (OU) is an organizational entity part of a company,
with separate management ownership. Management by OU is aimed to
introduce the following features:
AnThis module maintains the administrative units (Operating Units) to
which resources can be associated. An Operating Unit (OU) is a child of
a Company.

**Improvements in this version:**

- Added a Stat Button on Operating Units to easily view and manage
linked users. with separate management ownership. Management by OU is
aimed to introduce the following features:

- Data partitioning from other OU.

- Own sequencing schemes.

- User access administration for data processing and reporting.

- Product and customer independence of OU.

- OU specific P&L and Balance sheet.

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

**Stat Button for Linked Users**

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.

Known issues / Roadmap
======================

Expand Down Expand Up @@ -95,6 +107,9 @@ Contributors
- Andrea Stirpe <a.stirpe@onestein.nl>
- Ooops, Ashish Hirpara <ashish.hirapara1995@gmail.com>
- Daniel Lagin <daniel.lagin@braintec.com>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------
Expand Down
57 changes: 57 additions & 0 deletions operating_unit/models/operating_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,60 @@ def create(self, vals_list):
def write(self, vals):
self.env.registry.clear_cache()
return super().write(vals)

def button_open_linked_users(self):
self.ensure_one()
action = self.env.ref(
"base.action_res_users",
raise_if_not_found=False,
)
if not action:
return False
action_vals = action.read()[0]

user_ids = set(self.user_ids.ids)
group = self.env.ref(
"operating_unit.group_manager_operating_unit",
raise_if_not_found=False,
)
if group:
user_ids.update(group.users.ids)

user_ids = list(user_ids)

context = action_vals.get("context", {})
if isinstance(context, str):
from odoo.tools.safe_eval import safe_eval

context = safe_eval(context)

context.update(
{
"create": False,
"edit": False,
"delete": False,
}
)
action_vals["context"] = context

if not user_ids:
return action_vals

action_vals["domain"] = [("id", "in", user_ids)]
if len(user_ids) == 1:
form_view = self.env.ref("base.view_users_form")
action_vals.update(
{
"views": [(form_view.id, "form")],
"view_mode": "form",
"res_id": user_ids[0],
}
)
else:
action_vals.update(
{
"views": [(False, "list"), (False, "form")],
"view_mode": "list,form",
}
)
return action_vals
2 changes: 2 additions & 0 deletions operating_unit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
- Andrea Stirpe \<<a.stirpe@onestein.nl>\>
- Ooops, Ashish Hirpara \<<ashish.hirapara1995@gmail.com>\>
- Daniel Lagin \<<daniel.lagin@braintec.com>\>
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
7 changes: 6 additions & 1 deletion operating_unit/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
An operating unit (OU) is an organizational entity part of a company,
AnThis module maintains the administrative units (Operating Units) to which
resources can be associated. An Operating Unit (OU) is a child of a
Company.

**Improvements in this version:**
- Added a Stat Button on Operating Units to easily view and manage linked users.
with separate management ownership. Management by OU is aimed to
introduce the following features:

Expand Down
5 changes: 5 additions & 0 deletions operating_unit/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
This module defines the operating unit entity and the user's security
rules. Other modules extend the standard Odoo apps with the OU.

**Stat Button for Linked Users**

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.

48 changes: 27 additions & 21 deletions operating_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Operating Unit</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,25 +360,24 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="operating-unit">
<h1 class="title">Operating Unit</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="operating-unit">
<h1>Operating Unit</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ca21463eb1db9a29de1b428d7c782cf4c92fa40ded17fd42d07b55e41cd3697f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<p>An operating unit (OU) is an organizational entity part of a company,
with separate management ownership. Management by OU is aimed to
introduce the following features:</p>
<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>
<p>AnThis module maintains the administrative units (Operating Units) to
which resources can be associated. An Operating Unit (OU) is a child of
a Company.</p>
<p><strong>Improvements in this version:</strong></p>
<ul class="simple">
<li>Added a Stat Button on Operating Units to easily view and manage
linked users. with separate management ownership. Management by OU is
aimed to introduce the following features:</li>
<li>Data partitioning from other OU.</li>
<li>Own sequencing schemes.</li>
<li>User access administration for data processing and reporting.</li>
Expand All @@ -401,7 +400,7 @@ <h1>Operating Unit</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<ul class="simple">
<li>Assign <em>Multi Operating Unit</em> group to user.</li>
Expand All @@ -410,43 +409,51 @@ <h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>This module defines the operating unit entity and the user’s security
rules. Other modules extend the standard Odoo apps with the OU.</p>
<p><strong>Stat Button for Linked Users</strong></p>
<p>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.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/operating-unit/issues">GitHub Issues</a>.
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
<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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
<li>Serpent Consulting Services Pvt. Ltd.</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>ForgeFlow &lt;<a class="reference external" href="mailto:contact&#64;forgeflow.com">contact&#64;forgeflow.com</a>&gt;</li>
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
<li>Jarsa Sistemas &lt;<a class="reference external" href="mailto:info&#64;jarsa.com.mx">info&#64;jarsa.com.mx</a>&gt;</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Ooops, Ashish Hirpara &lt;<a class="reference external" href="mailto:ashish.hirapara1995&#64;gmail.com">ashish.hirapara1995&#64;gmail.com</a>&gt;</li>
<li>Daniel Lagin &lt;<a class="reference external" href="mailto:daniel.lagin&#64;braintec.com">daniel.lagin&#64;braintec.com</a>&gt;</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -459,6 +466,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
9 changes: 9 additions & 0 deletions operating_unit/tests/test_operating_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,12 @@ def test_create_multi_operating_unit(self):
self.assertEqual(res[0].user_ids, self.user1)
self.assertEqual(res[1].user_ids, self.user1)
self.assertEqual(res[2].user_ids, self.user1)

def test_button_open_linked_users(self):
"""Test the Stat Button that opens linked users."""
# Add another user to ou1
self._create_user("user_extra", self.grp_ou_multi, self.company, [self.ou1])
action = self.ou1.button_open_linked_users()
self.assertEqual(action["res_model"], "res.users")
self.assertEqual(action.get("view_mode"), "list,form")
self.assertIn("domain", action)
28 changes: 21 additions & 7 deletions operating_unit/view/operating_unit_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
<field name="model">operating.unit</field>
<field name="arch" type="xml">
<form string="Operating Unit">
<group name="main_group">
<field name="name" />
<field name="code" />
<field name="active" />
<field name="partner_id" />
<field name="company_id" groups="base.group_multi_company" />
</group>
<sheet>
<div class="oe_button_box" name="button_box">
<button
name="button_open_linked_users"
type="object"
class="oe_stat_button"
icon="fa-users"
>
<div class="o_stat_info">
<span class="o_stat_text">Users</span>
</div>
</button>
</div>
<group name="main_group">
<field name="name" />
<field name="code" />
<field name="active" />
<field name="partner_id" />
<field name="company_id" groups="base.group_multi_company" />
</group>
</sheet>
</form>
</field>
</record>
Expand Down
Loading