diff --git a/setup/stock_request_operating_unit/odoo/addons/stock_request_operating_unit b/setup/stock_request_operating_unit/odoo/addons/stock_request_operating_unit new file mode 120000 index 0000000000..8602cf0fe8 --- /dev/null +++ b/setup/stock_request_operating_unit/odoo/addons/stock_request_operating_unit @@ -0,0 +1 @@ +../../../../stock_request_operating_unit \ No newline at end of file diff --git a/setup/stock_request_operating_unit/setup.py b/setup/stock_request_operating_unit/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_request_operating_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/setup/stock_request_operating_unit_access_all/odoo/addons/stock_request_operating_unit_access_all b/setup/stock_request_operating_unit_access_all/odoo/addons/stock_request_operating_unit_access_all new file mode 120000 index 0000000000..f960a23a0b --- /dev/null +++ b/setup/stock_request_operating_unit_access_all/odoo/addons/stock_request_operating_unit_access_all @@ -0,0 +1 @@ +../../../../stock_request_operating_unit_access_all \ No newline at end of file diff --git a/setup/stock_request_operating_unit_access_all/setup.py b/setup/stock_request_operating_unit_access_all/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_request_operating_unit_access_all/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_request_operating_unit/README.rst b/stock_request_operating_unit/README.rst new file mode 100644 index 0000000000..9caa5c3b19 --- /dev/null +++ b/stock_request_operating_unit/README.rst @@ -0,0 +1,80 @@ +============================ +Stock Request Operating Unit +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:89902efe4a64926dddc0e0f296c9588b4fb7bf94967fc6f8949385870cbecbdd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/14.0/stock_request_operating_unit + :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-14-0/operating-unit-14-0-stock_request_operating_unit + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module introduces the operating unit to the Stock Request. +Security rules are defined to ensure that users can only display +the Stock Requests in which they are allowed access to. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* `Ecosoft `__: + + * Pimolnat Suntian + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_operating_unit/__init__.py b/stock_request_operating_unit/__init__.py new file mode 100644 index 0000000000..69f7babdfb --- /dev/null +++ b/stock_request_operating_unit/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_request_operating_unit/__manifest__.py b/stock_request_operating_unit/__manifest__.py new file mode 100644 index 0000000000..bfbeea0470 --- /dev/null +++ b/stock_request_operating_unit/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Request Operating Unit", + "summary": "Introduces Operating Unit (OU) in stock request", + "version": "14.0.1.0.0", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/operating-unit", + "category": "Warehouse Management", + "depends": ["stock_request", "operating_unit"], + "license": "AGPL-3", + "data": [ + "security/stock_request_security.xml", + "views/stock_request_views.xml", + "views/stock_request_order_views.xml", + ], + "installable": True, +} diff --git a/stock_request_operating_unit/models/__init__.py b/stock_request_operating_unit/models/__init__.py new file mode 100644 index 0000000000..03b754f692 --- /dev/null +++ b/stock_request_operating_unit/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_request +from . import stock_request_order diff --git a/stock_request_operating_unit/models/stock_request.py b/stock_request_operating_unit/models/stock_request.py new file mode 100644 index 0000000000..718fec4a35 --- /dev/null +++ b/stock_request_operating_unit/models/stock_request.py @@ -0,0 +1,52 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockRequest(models.Model): + _inherit = "stock.request" + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Operating Unit", + compute="_compute_operating_unit", + readonly=False, + store=True, + ) + + @api.depends("order_id", "order_id.operating_unit_id") + def _compute_operating_unit(self): + default_operating_unit = self.env["res.users"].operating_unit_default_get( + self.env.uid + ) + for record in self: + if record.order_id: + record.operating_unit_id = record.order_id.operating_unit_id + else: + record.operating_unit_id = default_operating_unit + + @api.constrains("operating_unit_id", "company_id") + def _check_company_operating_unit(self): + for record in self: + if ( + record.company_id + and record.operating_unit_id + and record.company_id != record.operating_unit_id.company_id + ): + raise ValidationError( + _( + "Configuration error. The Company in the Stock Request " + "and in the Operating Unit must be the same." + ) + ) + + def _prepare_procurement_values(self, group_id=False): + """ + Add operating unit to procurement values + """ + res = super()._prepare_procurement_values(group_id=group_id) + if self.operating_unit_id: + res.update({"operating_unit_id": self.operating_unit_id.id}) + return res diff --git a/stock_request_operating_unit/models/stock_request_order.py b/stock_request_operating_unit/models/stock_request_order.py new file mode 100644 index 0000000000..e4d0636a35 --- /dev/null +++ b/stock_request_operating_unit/models/stock_request_order.py @@ -0,0 +1,34 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class StockRequestOrder(models.Model): + _inherit = "stock.request.order" + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Operating Unit", + default=lambda self: ( + self.env["res.users"].operating_unit_default_get(self.env.uid) + ), + readonly=True, + states={"draft": [("readonly", False)]}, + ) + + @api.constrains("operating_unit_id", "company_id") + def _check_company_operating_unit(self): + for record in self: + if ( + record.company_id + and record.operating_unit_id + and record.company_id != record.operating_unit_id.company_id + ): + raise ValidationError( + _( + "Configuration error. The Company in the Stock Request " + "and in the Operating Unit must be the same." + ) + ) diff --git a/stock_request_operating_unit/readme/CONTRIBUTORS.rst b/stock_request_operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ea63aa7bc1 --- /dev/null +++ b/stock_request_operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/stock_request_operating_unit/readme/DESCRIPTION.rst b/stock_request_operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1039249546 --- /dev/null +++ b/stock_request_operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module introduces the operating unit to the Stock Request. +Security rules are defined to ensure that users can only display +the Stock Requests in which they are allowed access to. diff --git a/stock_request_operating_unit/security/stock_request_security.xml b/stock_request_operating_unit/security/stock_request_security.xml new file mode 100644 index 0000000000..a53b71c96c --- /dev/null +++ b/stock_request_operating_unit/security/stock_request_security.xml @@ -0,0 +1,25 @@ + + + + + ['|',('operating_unit_id','=',False), + ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Stock Request Orders from allowed operating units + + + + + + + + + ['|',('operating_unit_id','=',False), + ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Stock Requests from allowed operating units + + + + + + + diff --git a/stock_request_operating_unit/static/description/icon.png b/stock_request_operating_unit/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/stock_request_operating_unit/static/description/icon.png differ diff --git a/stock_request_operating_unit/static/description/index.html b/stock_request_operating_unit/static/description/index.html new file mode 100644 index 0000000000..a190311cbb --- /dev/null +++ b/stock_request_operating_unit/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Stock Request Operating Unit + + + +
+

Stock Request Operating Unit

+ + +

Beta License: AGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runboat

+

This module introduces the operating unit to the Stock Request. +Security rules are defined to ensure that users can only display +the Stock Requests in which they are allowed access to.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_request_operating_unit/views/stock_request_order_views.xml b/stock_request_operating_unit/views/stock_request_order_views.xml new file mode 100644 index 0000000000..b4cadd2873 --- /dev/null +++ b/stock_request_operating_unit/views/stock_request_order_views.xml @@ -0,0 +1,27 @@ + + + + stock.request.order.form + stock.request.order + + + + + + + + + + + diff --git a/stock_request_operating_unit/views/stock_request_views.xml b/stock_request_operating_unit/views/stock_request_views.xml new file mode 100644 index 0000000000..65f210affa --- /dev/null +++ b/stock_request_operating_unit/views/stock_request_views.xml @@ -0,0 +1,17 @@ + + + + stock.request.form + stock.request + + + + + + + + diff --git a/stock_request_operating_unit_access_all/README.rst b/stock_request_operating_unit_access_all/README.rst new file mode 100644 index 0000000000..ab1ea1eb1a --- /dev/null +++ b/stock_request_operating_unit_access_all/README.rst @@ -0,0 +1,91 @@ +============================= +Access all OUs' Stock Request +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f26fefc60ab96ac876232ce32e8ab2dadd2fe021ad4d9adbe8116d24e2c133cc + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/14.0/stock_request_operating_unit_access_all + :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-14-0/operating-unit-14-0-stock_request_operating_unit_access_all + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allow a user to have Access all OUs' stock requests, +without having to add OUs in user setting. + +Example use case, a shared team under an OU +but need to work on stock requests of all OUs. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + + +To configure a user to have access to all OUs' stock requests (without all OUs access): + +* Go to *Settings / Users & Companies / Users* +* For a user, select checkbox "Access all OUs' stock requests" + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* `Ecosoft `__: + + * Pimolnat Suntian + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_operating_unit_access_all/__manifest__.py b/stock_request_operating_unit_access_all/__manifest__.py new file mode 100644 index 0000000000..b67ce43c5c --- /dev/null +++ b/stock_request_operating_unit_access_all/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2023 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Access all OUs' Stock Request", + "version": "14.0.1.0.0", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/operating-unit", + "category": "Warehouse Management", + "depends": ["stock_request_operating_unit"], + "license": "AGPL-3", + "data": [ + "security/stock_request_security.xml", + ], + "installable": True, +} diff --git a/stock_request_operating_unit_access_all/readme/CONFIGURE.rst b/stock_request_operating_unit_access_all/readme/CONFIGURE.rst new file mode 100644 index 0000000000..166b2fa347 --- /dev/null +++ b/stock_request_operating_unit_access_all/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ + +To configure a user to have access to all OUs' stock requests (without all OUs access): + +* Go to *Settings / Users & Companies / Users* +* For a user, select checkbox "Access all OUs' stock requests" diff --git a/stock_request_operating_unit_access_all/readme/CONTRIBUTORS.rst b/stock_request_operating_unit_access_all/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ea63aa7bc1 --- /dev/null +++ b/stock_request_operating_unit_access_all/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Ecosoft `__: + + * Pimolnat Suntian diff --git a/stock_request_operating_unit_access_all/readme/DESCRIPTION.rst b/stock_request_operating_unit_access_all/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..62bc967024 --- /dev/null +++ b/stock_request_operating_unit_access_all/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module allow a user to have Access all OUs' stock requests, +without having to add OUs in user setting. + +Example use case, a shared team under an OU +but need to work on stock requests of all OUs. diff --git a/stock_request_operating_unit_access_all/security/stock_request_security.xml b/stock_request_operating_unit_access_all/security/stock_request_security.xml new file mode 100644 index 0000000000..828c7e2b1e --- /dev/null +++ b/stock_request_operating_unit_access_all/security/stock_request_security.xml @@ -0,0 +1,27 @@ + + + + + Access all OUs' stock requests + + + + + + + + + + + + + + diff --git a/stock_request_operating_unit_access_all/static/description/icon.png b/stock_request_operating_unit_access_all/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/stock_request_operating_unit_access_all/static/description/icon.png differ diff --git a/stock_request_operating_unit_access_all/static/description/index.html b/stock_request_operating_unit_access_all/static/description/index.html new file mode 100644 index 0000000000..2d8200f177 --- /dev/null +++ b/stock_request_operating_unit_access_all/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Access all OUs' Stock Request + + + +
+

Access all OUs’ Stock Request

+ + +

Beta License: AGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runboat

+

This module allow a user to have Access all OUs’ stock requests, +without having to add OUs in user setting.

+

Example use case, a shared team under an OU +but need to work on stock requests of all OUs.

+

Table of contents

+ +
+

Configuration

+

To configure a user to have access to all OUs’ stock requests (without all OUs access):

+
    +
  • Go to Settings / Users & Companies / Users
  • +
  • For a user, select checkbox “Access all OUs’ stock requests”
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ +