diff --git a/stock_request_tier_validation/README.rst b/stock_request_tier_validation/README.rst new file mode 100644 index 00000000..077edfab --- /dev/null +++ b/stock_request_tier_validation/README.rst @@ -0,0 +1,125 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================= +Stock Request Tier Validation +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a7fb0b6e627969fbe19e4cc380c814db90ac06e21df1c9967dcab33586e28553 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/license-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%2Ftier--validation-lightgray.png?logo=github + :target: https://github.com/OCA/tier-validation/tree/19.0/stock_request_tier_validation + :alt: OCA/tier-validation +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/tier-validation-19-0/tier-validation-19-0-stock_request_tier_validation + :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/tier-validation&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of Stock Requests and Stock +Request Orders to support a tier validation process. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +This module depends on the module ``stock_request`` available in the +`stock-logistics-request `__ +repository. + +Configuration +============= + +To configure this module, you need to: + +1. Go to *Settings > Technical > Tier Validations > Tier Definition*. +2. Create as many tiers as you want for Stock Request or Stock Request + Order models. + +Usage +===== + +To use this module, you need to: + +1. Create a Stock Request or a Stock Request Order triggering at least + one "Tier Definition". +2. Click on *Request Validation* button. +3. Under the tab *Reviews* have a look to pending reviews and their + statuses. +4. Once all reviews are validated click on *Confirm*. + +Additional features: + +- You can filter the Stock Requests and Stock Request Orders requesting + your review through the filter *Needs my Review*. +- User with rights to validate the Stock Request or Stock Request Order + (validate all tiers that would be generated) can directly do the + operation, this is, there is no need for her/him to request a + validation. + +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 +------- + +* Jarsa + +Contributors +------------ + +- `Jarsa `__: + + - Alan Ramos + +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/tier-validation `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_request_tier_validation/__init__.py b/stock_request_tier_validation/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/stock_request_tier_validation/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_request_tier_validation/__manifest__.py b/stock_request_tier_validation/__manifest__.py new file mode 100644 index 00000000..546976c3 --- /dev/null +++ b/stock_request_tier_validation/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2026 Jarsa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Request Tier Validation", + "summary": "Extends the functionality of Stock Requests to " + "support a tier validation process.", + "version": "19.0.1.0.0", + "category": "Warehouse Management", + "website": "https://github.com/OCA/tier-validation", + "author": "Jarsa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "development_status": "Alpha", + "depends": ["stock_request", "base_tier_validation"], + "data": [ + "views/stock_request_views.xml", + "views/stock_request_order_views.xml", + ], + "installable": True, +} diff --git a/stock_request_tier_validation/models/__init__.py b/stock_request_tier_validation/models/__init__.py new file mode 100644 index 00000000..91fd0df2 --- /dev/null +++ b/stock_request_tier_validation/models/__init__.py @@ -0,0 +1,3 @@ +from . import stock_request +from . import stock_request_order +from . import tier_definition diff --git a/stock_request_tier_validation/models/stock_request.py b/stock_request_tier_validation/models/stock_request.py new file mode 100644 index 00000000..6513da4b --- /dev/null +++ b/stock_request_tier_validation/models/stock_request.py @@ -0,0 +1,13 @@ +# Copyright 2026 Jarsa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockRequest(models.Model): + _name = "stock.request" + _inherit = ["stock.request", "tier.validation"] + _state_from = ["draft"] + _state_to = ["open"] + + _tier_validation_manual_config = False diff --git a/stock_request_tier_validation/models/stock_request_order.py b/stock_request_tier_validation/models/stock_request_order.py new file mode 100644 index 00000000..4c5e0355 --- /dev/null +++ b/stock_request_tier_validation/models/stock_request_order.py @@ -0,0 +1,38 @@ +# Copyright 2026 Jarsa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models +from odoo.exceptions import ValidationError + + +class StockRequestOrder(models.Model): + _name = "stock.request.order" + _inherit = ["stock.request.order", "tier.validation"] + _state_from = ["draft"] + _state_to = ["open"] + + _tier_validation_manual_config = False + # state is a stored computed field on stock.request.order + _tier_validation_state_field_is_computed = True + + def action_confirm(self): + # state is computed and flushed lazily, so validate explicitly + # before confirming instead of relying on the write() check + for rec in self: + if rec.need_validation: + reviews = rec.request_validation() + rec._validate_tier(reviews) + if rec.validation_status != "validated": + raise ValidationError( + self.env._( + "This action needs to be validated for at least " + "one record. \nPlease request a validation." + ) + ) + if rec.review_ids and rec.validation_status != "validated": + raise ValidationError( + self.env._( + "A validation process is still open for at least one record." + ) + ) + return super().action_confirm() diff --git a/stock_request_tier_validation/models/tier_definition.py b/stock_request_tier_validation/models/tier_definition.py new file mode 100644 index 00000000..1f05d41a --- /dev/null +++ b/stock_request_tier_validation/models/tier_definition.py @@ -0,0 +1,15 @@ +# Copyright 2026 Jarsa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class TierDefinition(models.Model): + _inherit = "tier.definition" + + @api.model + def _get_tier_validation_model_names(self): + res = super()._get_tier_validation_model_names() + res.append("stock.request") + res.append("stock.request.order") + return res diff --git a/stock_request_tier_validation/pyproject.toml b/stock_request_tier_validation/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/stock_request_tier_validation/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_request_tier_validation/readme/CONFIGURE.md b/stock_request_tier_validation/readme/CONFIGURE.md new file mode 100644 index 00000000..d976b9bf --- /dev/null +++ b/stock_request_tier_validation/readme/CONFIGURE.md @@ -0,0 +1,6 @@ +To configure this module, you need to: + +1. Go to *Settings \> Technical \> Tier Validations \> Tier + Definition*. +2. Create as many tiers as you want for Stock Request or Stock + Request Order models. diff --git a/stock_request_tier_validation/readme/CONTRIBUTORS.md b/stock_request_tier_validation/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..6a1b8eca --- /dev/null +++ b/stock_request_tier_validation/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Jarsa](https://www.jarsa.com): + - Alan Ramos \<\> diff --git a/stock_request_tier_validation/readme/DESCRIPTION.md b/stock_request_tier_validation/readme/DESCRIPTION.md new file mode 100644 index 00000000..4929ce92 --- /dev/null +++ b/stock_request_tier_validation/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of Stock Requests and Stock +Request Orders to support a tier validation process. diff --git a/stock_request_tier_validation/readme/INSTALL.md b/stock_request_tier_validation/readme/INSTALL.md new file mode 100644 index 00000000..3ce7247e --- /dev/null +++ b/stock_request_tier_validation/readme/INSTALL.md @@ -0,0 +1,3 @@ +This module depends on the module `stock_request` available in the +[stock-logistics-request](https://github.com/OCA/stock-logistics-request) +repository. diff --git a/stock_request_tier_validation/readme/USAGE.md b/stock_request_tier_validation/readme/USAGE.md new file mode 100644 index 00000000..43aa3c2d --- /dev/null +++ b/stock_request_tier_validation/readme/USAGE.md @@ -0,0 +1,17 @@ +To use this module, you need to: + +1. Create a Stock Request or a Stock Request Order triggering at least + one "Tier Definition". +2. Click on *Request Validation* button. +3. Under the tab *Reviews* have a look to pending reviews and their + statuses. +4. Once all reviews are validated click on *Confirm*. + +Additional features: + +- You can filter the Stock Requests and Stock Request Orders requesting + your review through the filter *Needs my Review*. +- User with rights to validate the Stock Request or Stock Request Order + (validate all tiers that would be generated) can directly do the + operation, this is, there is no need for her/him to request a + validation. diff --git a/stock_request_tier_validation/static/description/icon.png b/stock_request_tier_validation/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/stock_request_tier_validation/static/description/icon.png differ diff --git a/stock_request_tier_validation/static/description/index.html b/stock_request_tier_validation/static/description/index.html new file mode 100644 index 00000000..1d63dbe3 --- /dev/null +++ b/stock_request_tier_validation/static/description/index.html @@ -0,0 +1,478 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Stock Request Tier Validation

+ +

Alpha License: AGPL-3 OCA/tier-validation Translate me on Weblate Try me on Runboat

+

This module extends the functionality of Stock Requests and Stock +Request Orders to support a tier validation process.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Installation

+

This module depends on the module stock_request available in the +stock-logistics-request +repository.

+
+
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Settings > Technical > Tier Validations > Tier Definition.
  2. +
  3. Create as many tiers as you want for Stock Request or Stock Request +Order models.
  4. +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Create a Stock Request or a Stock Request Order triggering at least +one “Tier Definition”.
  2. +
  3. Click on Request Validation button.
  4. +
  5. Under the tab Reviews have a look to pending reviews and their +statuses.
  6. +
  7. Once all reviews are validated click on Confirm.
  8. +
+

Additional features:

+
    +
  • You can filter the Stock Requests and Stock Request Orders requesting +your review through the filter Needs my Review.
  • +
  • User with rights to validate the Stock Request or Stock Request Order +(validate all tiers that would be generated) can directly do the +operation, this is, there is no need for her/him to request a +validation.
  • +
+
+
+

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

+
    +
  • Jarsa
  • +
+
+
+

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

+

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

+
+
+
+
+ + diff --git a/stock_request_tier_validation/tests/__init__.py b/stock_request_tier_validation/tests/__init__.py new file mode 100644 index 00000000..b411f6a3 --- /dev/null +++ b/stock_request_tier_validation/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_request_tier_validation diff --git a/stock_request_tier_validation/tests/test_stock_request_tier_validation.py b/stock_request_tier_validation/tests/test_stock_request_tier_validation.py new file mode 100644 index 00000000..0daf5229 --- /dev/null +++ b/stock_request_tier_validation/tests/test_stock_request_tier_validation.py @@ -0,0 +1,151 @@ +# Copyright 2026 Jarsa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import Command, fields +from odoo.exceptions import ValidationError +from odoo.tests import tagged +from odoo.tests.common import new_test_user + +from odoo.addons.base.tests.common import BaseCommon + + +@tagged("post_install", "-at_install") +class TestStockRequestTierValidation(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.company = cls.env.ref("base.main_company") + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.test_user = new_test_user( + cls.env, + name="Test Reviewer", + login="test_reviewer", + groups="base.group_system,stock_request.group_stock_request_manager", + ) + cls.env["tier.definition"].create( + { + "model_id": cls.env.ref("stock_request.model_stock_request").id, + "review_type": "individual", + "reviewer_id": cls.test_user.id, + "definition_domain": ( + "[('state', '=', 'draft'), ('order_id', '=', False)]" + ), + } + ) + cls.env["tier.definition"].create( + { + "model_id": cls.env.ref("stock_request.model_stock_request_order").id, + "review_type": "individual", + "reviewer_id": cls.test_user.id, + "definition_domain": "[('state', '=', 'draft')]", + } + ) + cls.product = cls.env["product.product"].create( + { + "name": "Test Product", + "type": "consu", + "is_storable": True, + } + ) + cls.ressuply_loc = cls.env["stock.location"].create( + { + "name": "Ressuply", + "usage": "internal", + "location_id": cls.warehouse.view_location_id.id, + "company_id": cls.company.id, + } + ) + cls.route = cls.env["stock.route"].create( + { + "name": "Transfer", + "product_selectable": True, + "company_id": cls.company.id, + "rule_ids": [ + Command.create( + { + "name": "Transfer", + "location_src_id": cls.ressuply_loc.id, + "location_dest_id": cls.warehouse.lot_stock_id.id, + "action": "pull", + "picking_type_id": cls.warehouse.int_type_id.id, + "procure_method": "make_to_stock", + "warehouse_id": cls.warehouse.id, + "company_id": cls.company.id, + } + ) + ], + } + ) + cls.product.route_ids = [Command.set(cls.route.ids)] + + def test_tier_validation(self): + request = self.env["stock.request"].create( + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": fields.Datetime.now(), + } + ) + msg_error_received = ( + r"(?s)This action needs to be validated for at least one record\..*" + r"Please request a validation\." + ) + with self.assertRaisesRegex(ValidationError, msg_error_received): + request.action_confirm() + request.request_validation() + request.invalidate_model() + msg_error_open = ( + r"(?s)A validation process is still open for at least one record\." + ) + with self.assertRaisesRegex(ValidationError, msg_error_open): + request.action_confirm() + request.with_user(self.test_user).validate_tier() + request.invalidate_model() + request.action_confirm() + self.assertEqual(request.state, "open") + self.assertEqual(request.validation_status, "validated") + + def test_tier_validation_order(self): + order = self.env["stock.request.order"].create( + { + "company_id": self.company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": fields.Datetime.now(), + "stock_request_ids": [ + Command.create( + { + "product_id": self.product.id, + "product_uom_id": self.product.uom_id.id, + "product_uom_qty": 5.0, + "company_id": self.company.id, + "warehouse_id": self.warehouse.id, + "location_id": self.warehouse.lot_stock_id.id, + "expected_date": fields.Datetime.now(), + } + ) + ], + } + ) + msg_error_received = ( + r"(?s)This action needs to be validated for at least one record\..*" + r"Please request a validation\." + ) + with self.assertRaisesRegex(ValidationError, msg_error_received): + order.action_confirm() + order.request_validation() + order.invalidate_model() + msg_error_open = ( + r"(?s)A validation process is still open for at least one record\." + ) + with self.assertRaisesRegex(ValidationError, msg_error_open): + order.action_confirm() + order.with_user(self.test_user).validate_tier() + order.invalidate_model() + order.action_confirm() + self.assertEqual(order.state, "open") + self.assertEqual(order.validation_status, "validated") diff --git a/stock_request_tier_validation/views/stock_request_order_views.xml b/stock_request_tier_validation/views/stock_request_order_views.xml new file mode 100644 index 00000000..fd636b41 --- /dev/null +++ b/stock_request_tier_validation/views/stock_request_order_views.xml @@ -0,0 +1,30 @@ + + + + + stock.request.order.search - stock_request_tier_validation + stock.request.order + + + + + + + + + + + diff --git a/stock_request_tier_validation/views/stock_request_views.xml b/stock_request_tier_validation/views/stock_request_views.xml new file mode 100644 index 00000000..fa63b34e --- /dev/null +++ b/stock_request_tier_validation/views/stock_request_views.xml @@ -0,0 +1,28 @@ + + + + + stock.request.search - stock_request_tier_validation + stock.request + + + + + + + + + + +