diff --git a/stock_picking_origin_reference_purchase/README.rst b/stock_picking_origin_reference_purchase/README.rst new file mode 100644 index 000000000000..9950736195f1 --- /dev/null +++ b/stock_picking_origin_reference_purchase/README.rst @@ -0,0 +1,81 @@ +======================================= +Stock Picking Origin Reference Purchase +======================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5267df2b665b089417fbb327096157807cd71894d35c2c22ac6c13748ce18f37 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/18.0/stock_picking_origin_reference_purchase + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-18-0/stock-logistics-workflow-18-0-stock_picking_origin_reference_purchase + :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/stock-logistics-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the stock_picking_origin_reference features by +adding Purchase Orders as one of the possible referenced documents. + +**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 + +Contributors +------------ + +- ForgeFlow S.L. + + - Guillem Casassas + +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +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/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_origin_reference_purchase/__init__.py b/stock_picking_origin_reference_purchase/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/stock_picking_origin_reference_purchase/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_origin_reference_purchase/__manifest__.py b/stock_picking_origin_reference_purchase/__manifest__.py new file mode 100644 index 000000000000..0df69be5fb2a --- /dev/null +++ b/stock_picking_origin_reference_purchase/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Picking Origin Reference Purchase", + "summary": "Transfer to Purchase Order navigation from the Source Document.", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "website": "https://github.com/OCA/stock-logistics-workflow", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "category": "Warehouse Management", + "depends": ["stock_picking_origin_reference", "purchase"], + "installable": True, + "application": False, + "auto_install": True, +} diff --git a/stock_picking_origin_reference_purchase/i18n/it.po b/stock_picking_origin_reference_purchase/i18n/it.po new file mode 100644 index 000000000000..7172b3e7094f --- /dev/null +++ b/stock_picking_origin_reference_purchase/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_origin_reference_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-24 10:33+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: stock_picking_origin_reference_purchase +#: model:ir.model,name:stock_picking_origin_reference_purchase.model_stock_picking +msgid "Transfer" +msgstr "Trasferimento" diff --git a/stock_picking_origin_reference_purchase/i18n/stock_picking_origin_reference_purchase.pot b/stock_picking_origin_reference_purchase/i18n/stock_picking_origin_reference_purchase.pot new file mode 100644 index 000000000000..32488bfe642f --- /dev/null +++ b/stock_picking_origin_reference_purchase/i18n/stock_picking_origin_reference_purchase.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_origin_reference_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_picking_origin_reference_purchase +#: model:ir.model,name:stock_picking_origin_reference_purchase.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_origin_reference_purchase/models/__init__.py b/stock_picking_origin_reference_purchase/models/__init__.py new file mode 100644 index 000000000000..ae4c27227f18 --- /dev/null +++ b/stock_picking_origin_reference_purchase/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/stock_picking_origin_reference_purchase/models/stock_picking.py b/stock_picking_origin_reference_purchase/models/stock_picking.py new file mode 100644 index 000000000000..e0abf628cecb --- /dev/null +++ b/stock_picking_origin_reference_purchase/models/stock_picking.py @@ -0,0 +1,26 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, models + +PO_MODEL_NAME = "purchase.order" + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + def _selection_origin_reference(self): + return super()._selection_origin_reference() + [ + (PO_MODEL_NAME, "Purchase Order") + ] + + @api.depends(lambda x: x._get_depends_compute_origin_reference()) + def _compute_origin_reference(self): + res = super()._compute_origin_reference() + for picking in self: + if not picking.origin_reference: + rel_purchase = self.env[PO_MODEL_NAME].search( + [("name", "=", picking.origin)], limit=1 + ) + if rel_purchase: + picking.origin_reference = f"{PO_MODEL_NAME},{rel_purchase.id}" + return res diff --git a/stock_picking_origin_reference_purchase/pyproject.toml b/stock_picking_origin_reference_purchase/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/stock_picking_origin_reference_purchase/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_picking_origin_reference_purchase/readme/CONTRIBUTORS.md b/stock_picking_origin_reference_purchase/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..c231d74e08d8 --- /dev/null +++ b/stock_picking_origin_reference_purchase/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- ForgeFlow S.L. + - Guillem Casassas \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/stock_picking_origin_reference_purchase/readme/DESCRIPTION.md b/stock_picking_origin_reference_purchase/readme/DESCRIPTION.md new file mode 100644 index 000000000000..5122885fcf5d --- /dev/null +++ b/stock_picking_origin_reference_purchase/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the stock_picking_origin_reference features by +adding Purchase Orders as one of the possible referenced documents. diff --git a/stock_picking_origin_reference_purchase/static/description/icon.png b/stock_picking_origin_reference_purchase/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_picking_origin_reference_purchase/static/description/icon.png differ diff --git a/stock_picking_origin_reference_purchase/static/description/index.html b/stock_picking_origin_reference_purchase/static/description/index.html new file mode 100644 index 000000000000..412513a1fca8 --- /dev/null +++ b/stock_picking_origin_reference_purchase/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Stock Picking Origin Reference Purchase + + + +
+

Stock Picking Origin Reference Purchase

+ + +

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runboat

+

This module extends the stock_picking_origin_reference features by +adding Purchase Orders as one of the possible referenced documents.

+

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
  • +
+
+
+

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/stock-logistics-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_picking_origin_reference_purchase/tests/__init__.py b/stock_picking_origin_reference_purchase/tests/__init__.py new file mode 100644 index 000000000000..4f0f8896d228 --- /dev/null +++ b/stock_picking_origin_reference_purchase/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_origin_reference_purchase diff --git a/stock_picking_origin_reference_purchase/tests/test_stock_picking_origin_reference_purchase.py b/stock_picking_origin_reference_purchase/tests/test_stock_picking_origin_reference_purchase.py new file mode 100644 index 000000000000..9281c349e96c --- /dev/null +++ b/stock_picking_origin_reference_purchase/tests/test_stock_picking_origin_reference_purchase.py @@ -0,0 +1,52 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields + +from odoo.addons.stock_picking_origin_reference.tests import ( + test_stock_picking_origin_reference, +) + + +class TestStockPickingOriginReferencePurchase( + test_stock_picking_origin_reference.TestStockPickingOriginReference +): + def setUp(self): + super().setUp() + self.purchase_model = self.env["purchase.order"] + + def _create_purchase(self, partner, product): + purchase = self.purchase_model.create( + { + "partner_id": partner.id, + "order_line": [ + ( + 0, + 0, + { + "name": product.name, + "product_id": product.id, + "product_qty": 5, + "product_uom": product.uom_id.id, + "price_unit": 500, + "date_planned": fields.datetime.now(), + }, + ) + ], + } + ) + return purchase + + def test_01_check_correct_value(self): + """ + Check that the Transfer created from the purchase is referencing it. + """ + purchase = self._create_purchase(self.partner, self.product) + purchase.button_confirm() + self.assertTrue(purchase.picking_ids) + self.assertEqual( + len(purchase.picking_ids), 1, "Only one Transfer should be created." + ) + picking = purchase.picking_ids + self.assertEqual( + picking.origin_reference, purchase, "The Transfer should reference the PO." + )