-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] operating_unit_selector_widget
- Loading branch information
1 parent
88355e7
commit ac20953
Showing
24 changed files
with
1,113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
================================ | ||
Operating Unit - Selector Widget | ||
================================ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:a52b68f6bd7b57c3b6ee835e0bee09129e747eafb86e420a384d3b12a65d4837 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/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 | ||
:target: https://github.com/OCA/operating-unit/tree/17.0/operating_unit_selector_widget | ||
:alt: OCA/operating-unit | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/operating-unit-17-0/operating-unit-17-0-operating_unit_selector_widget | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Add a new widget to choose the wanted operating units and only view | ||
datas related to these operating units | ||
|
||
|image| | ||
|
||
.. |image| image:: https://raw.githubusercontent.com/OCA/operating-unit/17.0/operating_unit_selector_widget/static/description/widget.png | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Install the module and be sure to have an user with several operating | ||
units. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/issues>`_. | ||
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 | ||
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20operating_unit_selector_widget%0Aversion:%2017.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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Jérémy Didderen | ||
|
||
Contributors | ||
------------ | ||
|
||
- Jérémy Didderen | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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. | ||
|
||
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/17.0/operating_unit_selector_widget>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024-TODAY Jérémy Didderen | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
{ | ||
"name": "Operating Unit - Selector Widget", | ||
"summary": "Widget dedicated to choose the active operating units.", | ||
"version": "17.0.1.0.0", | ||
"author": "Jérémy Didderen, " "Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/operating-unit", | ||
"category": "Generic", | ||
"depends": [ | ||
"operating_unit", | ||
], | ||
"license": "LGPL-3", | ||
"assets": { | ||
"web.assets_backend": [ | ||
"operating_unit_selector_widget/static/src/operating_unit_service.esm.js", | ||
"operating_unit_selector_widget/static/src/switch_operating_unit_menu/switch_operating_unit_menu.xml", | ||
"operating_unit_selector_widget/static/src/switch_operating_unit_menu/switch_operating_unit_menu.esm.js", | ||
], | ||
"web.qunit_suite_tests": ["operating_unit_selector_widget/static/tests/*.js"], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import ir_http | ||
from . import res_users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2024-TODAY Jérémy Didderen | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from odoo import models | ||
|
||
|
||
class Http(models.AbstractModel): | ||
_inherit = "ir.http" | ||
|
||
def session_info(self): | ||
session_info = super().session_info() | ||
user = self.env.user | ||
is_internal_user = user.has_group("base.group_user") | ||
if is_internal_user: | ||
session_info.update( | ||
{ | ||
"user_ous": { | ||
"current_ou": user.default_operating_unit_id.id, | ||
"allowed_ous": { | ||
ou.id: { | ||
"id": ou.id, | ||
"name": ou.name, | ||
"sequence": ou.sequence, | ||
} | ||
for ou in user.operating_unit_ids | ||
}, | ||
}, | ||
} | ||
) | ||
return session_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024-TODAY Jérémy Didderen | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
import logging | ||
|
||
from odoo import _, models | ||
from odoo.exceptions import AccessError | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class ResUsers(models.Model): | ||
_inherit = "res.users" | ||
|
||
def operating_units(self): | ||
operating_unit_ids = self.env.context.get("allowed_ou_ids", []) | ||
user_ou_ids = self.operating_unit_ids.ids | ||
if operating_unit_ids: | ||
if not self.env.su: | ||
if set(operating_unit_ids) - set(user_ou_ids): | ||
raise AccessError(_("Access to unauthorized or invalid companies.")) | ||
return self.env["operating.unit"].browse(operating_unit_ids) | ||
return self.env["operating.unit"].browse(user_ou_ids) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Jérémy Didderen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Add a new widget to choose the wanted operating units and only view datas related to these operating units | ||
|
||
![image](../static/description/widget.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Install the module and be sure to have an user with several operating units. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.