diff --git a/ddmrp_purchase_approved/README.rst b/ddmrp_purchase_approved/README.rst new file mode 100644 index 000000000..4e6b99675 --- /dev/null +++ b/ddmrp_purchase_approved/README.rst @@ -0,0 +1,89 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================= +DDMRP Purchase Approved +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:af4ab287e49e8204e27128e369fdba637c8715a5482c1e753780d0e09027c5d0 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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%2Fddmrp-lightgray.png?logo=github + :target: https://github.com/OCA/ddmrp/tree/16.0/ddmrp_purchase_approved + :alt: OCA/ddmrp +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/ddmrp-16-0/ddmrp-16-0-ddmrp_purchase_approved + :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/ddmrp&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module between **DDMRP** and **Purchase Order Approved**. + +The `purchase_order_approved` module adds an intermediate "approved" state to +purchase orders. Without this glue module, DDMRP ignores PO lines in the +"approved" state because `_get_rfq_dlt()` only considers draft, sent, and +to-approve states. + +This module extends the `_get_unconfirmed_po_states()` hook on `stock.buffer` +to include the "approved" state, ensuring that approved purchase orders are +visible to DDMRP buffer calculations. + +**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 +~~~~~~~ + +* ForgeFlow S.L. + +Contributors +~~~~~~~~~~~~ + +* David Jiménez + +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/ddmrp `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/ddmrp_purchase_approved/__init__.py b/ddmrp_purchase_approved/__init__.py new file mode 100644 index 000000000..ae1ba6058 --- /dev/null +++ b/ddmrp_purchase_approved/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import models diff --git a/ddmrp_purchase_approved/__manifest__.py b/ddmrp_purchase_approved/__manifest__.py new file mode 100644 index 000000000..348465711 --- /dev/null +++ b/ddmrp_purchase_approved/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "DDMRP Purchase Approved", + "summary": "Include approved purchase orders in DDMRP incoming supply.", + "version": "16.0.1.0.0", + "author": "ForgeFlow S.L.,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/ddmrp", + "category": "Warehouse Management", + "depends": ["ddmrp", "purchase_order_approved"], + "license": "AGPL-3", + "installable": True, + "auto_install": True, +} diff --git a/ddmrp_purchase_approved/models/__init__.py b/ddmrp_purchase_approved/models/__init__.py new file mode 100644 index 000000000..86bf1a687 --- /dev/null +++ b/ddmrp_purchase_approved/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_buffer diff --git a/ddmrp_purchase_approved/models/stock_buffer.py b/ddmrp_purchase_approved/models/stock_buffer.py new file mode 100644 index 000000000..e4b61393a --- /dev/null +++ b/ddmrp_purchase_approved/models/stock_buffer.py @@ -0,0 +1,11 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockBuffer(models.Model): + _inherit = "stock.buffer" + + def _get_unconfirmed_po_states(self): + return super()._get_unconfirmed_po_states() + ("approved",) diff --git a/ddmrp_purchase_approved/readme/CONTRIBUTORS.rst b/ddmrp_purchase_approved/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..fcd081018 --- /dev/null +++ b/ddmrp_purchase_approved/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* David Jiménez diff --git a/ddmrp_purchase_approved/readme/DESCRIPTION.rst b/ddmrp_purchase_approved/readme/DESCRIPTION.rst new file mode 100644 index 000000000..2e090f6b7 --- /dev/null +++ b/ddmrp_purchase_approved/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ +Glue module between **DDMRP** and **Purchase Order Approved**. + +The `purchase_order_approved` module adds an intermediate "approved" state to +purchase orders. Without this glue module, DDMRP ignores PO lines in the +"approved" state because `_get_rfq_dlt()` only considers draft, sent, and +to-approve states. + +This module extends the `_get_unconfirmed_po_states()` hook on `stock.buffer` +to include the "approved" state, ensuring that approved purchase orders are +visible to DDMRP buffer calculations. diff --git a/ddmrp_purchase_approved/static/description/index.html b/ddmrp_purchase_approved/static/description/index.html new file mode 100644 index 000000000..a0d7f2545 --- /dev/null +++ b/ddmrp_purchase_approved/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

DDMRP Purchase Approved

+ +

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

+

Glue module between DDMRP and Purchase Order Approved.

+

The purchase_order_approved module adds an intermediate “approved” state to +purchase orders. Without this glue module, DDMRP ignores PO lines in the +“approved” state because _get_rfq_dlt() only considers draft, sent, and +to-approve states.

+

This module extends the _get_unconfirmed_po_states() hook on stock.buffer +to include the “approved” state, ensuring that approved purchase orders are +visible to DDMRP buffer calculations.

+

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

+
    +
  • ForgeFlow S.L.
  • +
+
+
+

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

+

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

+
+
+
+
+ + diff --git a/ddmrp_purchase_approved/tests/__init__.py b/ddmrp_purchase_approved/tests/__init__.py new file mode 100644 index 000000000..9fbd5c655 --- /dev/null +++ b/ddmrp_purchase_approved/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_ddmrp_purchase_approved diff --git a/ddmrp_purchase_approved/tests/test_ddmrp_purchase_approved.py b/ddmrp_purchase_approved/tests/test_ddmrp_purchase_approved.py new file mode 100644 index 000000000..f25949321 --- /dev/null +++ b/ddmrp_purchase_approved/tests/test_ddmrp_purchase_approved.py @@ -0,0 +1,58 @@ +# Copyright 2026 ForgeFlow S.L. (http://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields +from odoo.tests import tagged + +from odoo.addons.ddmrp.tests.common import TestDdmrpCommon + + +@tagged("post_install", "-at_install") +class TestDDMRPPurchaseApproved(TestDdmrpCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.po_model = cls.env["purchase.order"] + cls.pol_model = cls.env["purchase.order.line"] + cls.vendor = cls.partner_model.create({"name": "Test Vendor Approved"}) + + def _create_po_line(self, qty=10.0, state="draft"): + po = self.po_model.create({"partner_id": self.vendor.id}) + pol = self.pol_model.create( + { + "order_id": po.id, + "product_id": self.product_purchased.id, + "product_qty": qty, + "product_uom": self.product_purchased.uom_id.id, + "price_unit": 100.0, + "date_planned": fields.Datetime.now(), + "name": "Test", + } + ) + if state != "draft": + po.write({"state": state}) + return po, pol + + def test_01_approved_in_purchase_order_states(self): + """The 'approved' state must be included in DDMRP PO states.""" + states = self.buffer_purchase._get_unconfirmed_po_states() + self.assertIn("approved", states) + + def test_02_buffer_rfq_qty_through_state_transitions(self): + """Full lifecycle: draft -> approved -> purchase. + RFQ qty must reflect the PO only in draft/approved states.""" + buf = self.buffer_purchase + buf.cron_actions() + self.assertEqual(buf.rfq_total_qty, 0.0) + + po, pol = self._create_po_line(qty=25.0, state="draft") + buf.cron_actions() + self.assertEqual(buf.rfq_total_qty, 25.0) + + po.write({"state": "approved"}) + buf.cron_actions() + self.assertEqual(buf.rfq_total_qty, 25.0) + + po.write({"state": "purchase"}) + buf.cron_actions() + self.assertEqual(buf.rfq_total_qty, 0.0) diff --git a/setup/ddmrp_purchase_approved/odoo/addons/ddmrp_purchase_approved b/setup/ddmrp_purchase_approved/odoo/addons/ddmrp_purchase_approved new file mode 120000 index 000000000..54bc588e6 --- /dev/null +++ b/setup/ddmrp_purchase_approved/odoo/addons/ddmrp_purchase_approved @@ -0,0 +1 @@ +../../../../ddmrp_purchase_approved \ No newline at end of file diff --git a/setup/ddmrp_purchase_approved/setup.py b/setup/ddmrp_purchase_approved/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/ddmrp_purchase_approved/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)