diff --git a/stock_picking_origin_reference/README.rst b/stock_picking_origin_reference/README.rst new file mode 100644 index 000000000000..542f55afbc99 --- /dev/null +++ b/stock_picking_origin_reference/README.rst @@ -0,0 +1,102 @@ +============================== +Stock Picking Origin Reference +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:6c29ced90633d4be714498b18069c48996a83f1333559ee270be87198a22be86 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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 + :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 + :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| + +The Source Document contains a text referencing to the Odoo document +from which the transfer has been created. This module replaces the +Source Document field for a field with the same label which is clickable +and redirects the user to the document. + +If there is an existing Odoo document with the same name as the value in +the Source Document, the Odoo field is hidden, and the new field is +shown by default. Otherwise, it's left as it is. + +It also adds the base strucuture in order to reference documents from +different Odoo models. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +By just installing this module, the stock_picking_origin_reference_sale +and stock_picking_origin_reference_purchase modules are auto-installed, +if you have corresponding *extension* modules installed, such as sale +and purchase respectively. + +These two modules together with this one, will enable the navigation to +Sales Orders, Purchase Orders and Transfers. All possible referenced +models used in Odoo by default. + +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/__init__.py b/stock_picking_origin_reference/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/stock_picking_origin_reference/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_origin_reference/__manifest__.py b/stock_picking_origin_reference/__manifest__.py new file mode 100644 index 000000000000..8c29e8f0e533 --- /dev/null +++ b/stock_picking_origin_reference/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2023-2024 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", + "summary": "Add clickable button to the Transfer 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"], + "data": ["views/stock_picking_views.xml"], + "installable": True, + "application": False, +} diff --git a/stock_picking_origin_reference/i18n/it.po b/stock_picking_origin_reference/i18n/it.po new file mode 100644 index 000000000000..2bc83cfbc21a --- /dev/null +++ b/stock_picking_origin_reference/i18n/it.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_origin_reference +# +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 +#: model:ir.model.fields,field_description:stock_picking_origin_reference.field_stock_picking__origin_reference +msgid "Source Document" +msgstr "Documento di origine" + +#. module: stock_picking_origin_reference +#: model:ir.model,name:stock_picking_origin_reference.model_stock_picking +msgid "Transfer" +msgstr "Trasferimento" diff --git a/stock_picking_origin_reference/i18n/stock_picking_origin_reference.pot b/stock_picking_origin_reference/i18n/stock_picking_origin_reference.pot new file mode 100644 index 000000000000..2db5f14b4c8b --- /dev/null +++ b/stock_picking_origin_reference/i18n/stock_picking_origin_reference.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_origin_reference +# +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 +#: model:ir.model.fields,field_description:stock_picking_origin_reference.field_stock_picking__origin_reference +msgid "Source Document" +msgstr "" + +#. module: stock_picking_origin_reference +#: model:ir.model,name:stock_picking_origin_reference.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_origin_reference/models/__init__.py b/stock_picking_origin_reference/models/__init__.py new file mode 100644 index 000000000000..ae4c27227f18 --- /dev/null +++ b/stock_picking_origin_reference/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/stock_picking_origin_reference/models/stock_picking.py b/stock_picking_origin_reference/models/stock_picking.py new file mode 100644 index 000000000000..a300a3e4f77f --- /dev/null +++ b/stock_picking_origin_reference/models/stock_picking.py @@ -0,0 +1,28 @@ +# Copyright 2023-2024 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + origin_reference = fields.Reference( + selection="_selection_origin_reference", + compute="_compute_origin_reference", + ) + + def _selection_origin_reference(self): + return [("stock.picking", "Transfer")] + + @api.model + def _get_depends_compute_origin_reference(self): + return ["origin"] + + @api.depends(lambda x: x._get_depends_compute_origin_reference()) + def _compute_origin_reference(self): + for picking in self: + origin_reference = False + rel_picking = self.search([("name", "=", picking.origin)], limit=1) + if rel_picking: + origin_reference = f"{self._name},{rel_picking.id}" + picking.origin_reference = origin_reference diff --git a/stock_picking_origin_reference/pyproject.toml b/stock_picking_origin_reference/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/stock_picking_origin_reference/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_picking_origin_reference/readme/CONFIGURE.md b/stock_picking_origin_reference/readme/CONFIGURE.md new file mode 100644 index 000000000000..a1c97e001aa4 --- /dev/null +++ b/stock_picking_origin_reference/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +By just installing this module, the stock_picking_origin_reference_sale +and stock_picking_origin_reference_purchase modules are auto-installed, +if you have corresponding *extension* modules installed, such as sale +and purchase respectively. + +These two modules together with this one, will enable the navigation to +Sales Orders, Purchase Orders and Transfers. All possible referenced +models used in Odoo by default. diff --git a/stock_picking_origin_reference/readme/CONTRIBUTORS.md b/stock_picking_origin_reference/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..c231d74e08d8 --- /dev/null +++ b/stock_picking_origin_reference/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- ForgeFlow S.L. + - Guillem Casassas \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/stock_picking_origin_reference/readme/DESCRIPTION.md b/stock_picking_origin_reference/readme/DESCRIPTION.md new file mode 100644 index 000000000000..6a0ef06615c1 --- /dev/null +++ b/stock_picking_origin_reference/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +The Source Document contains a text referencing to the Odoo document +from which the transfer has been created. This module replaces the +Source Document field for a field with the same label which is clickable +and redirects the user to the document. + +If there is an existing Odoo document with the same name as the value in +the Source Document, the Odoo field is hidden, and the new field is +shown by default. Otherwise, it's left as it is. + +It also adds the base strucuture in order to reference documents from +different Odoo models. diff --git a/stock_picking_origin_reference/static/description/icon.png b/stock_picking_origin_reference/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/stock_picking_origin_reference/static/description/icon.png differ diff --git a/stock_picking_origin_reference/static/description/index.html b/stock_picking_origin_reference/static/description/index.html new file mode 100644 index 000000000000..920745264380 --- /dev/null +++ b/stock_picking_origin_reference/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +Stock Picking Origin Reference + + + +
+

Stock Picking Origin Reference

+ + +

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

+

The Source Document contains a text referencing to the Odoo document +from which the transfer has been created. This module replaces the +Source Document field for a field with the same label which is clickable +and redirects the user to the document.

+

If there is an existing Odoo document with the same name as the value in +the Source Document, the Odoo field is hidden, and the new field is +shown by default. Otherwise, it’s left as it is.

+

It also adds the base strucuture in order to reference documents from +different Odoo models.

+

Table of contents

+ +
+

Configuration

+

By just installing this module, the stock_picking_origin_reference_sale +and stock_picking_origin_reference_purchase modules are auto-installed, +if you have corresponding extension modules installed, such as sale +and purchase respectively.

+

These two modules together with this one, will enable the navigation to +Sales Orders, Purchase Orders and Transfers. All possible referenced +models used in Odoo by default.

+
+
+

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/tests/__init__.py b/stock_picking_origin_reference/tests/__init__.py new file mode 100644 index 000000000000..6ef04150a067 --- /dev/null +++ b/stock_picking_origin_reference/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_origin_reference diff --git a/stock_picking_origin_reference/tests/test_stock_picking_origin_reference.py b/stock_picking_origin_reference/tests/test_stock_picking_origin_reference.py new file mode 100644 index 000000000000..c4c0989b2580 --- /dev/null +++ b/stock_picking_origin_reference/tests/test_stock_picking_origin_reference.py @@ -0,0 +1,61 @@ +# Copyright 2023-2024 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.tests.common import TransactionCase + + +class TestStockPickingOriginReference(TransactionCase): + def setUp(self): + super().setUp() + # Models + self.picking_model = self.env["stock.picking"] + + # Existing Instances + self.picking_type_in_id = self.env.ref("stock.picking_type_in") + self.picking_type_out_id = self.env.ref("stock.picking_type_out") + self.location_suppliers = self.env.ref("stock.stock_location_suppliers") + self.location_stock = self.env.ref("stock.stock_location_stock") + self.location_customers = self.env.ref("stock.stock_location_customers") + + # TO BE USED IN CHILDREN TESTS + self.partner_model = self.env["res.partner"] + + self.product = self.env.ref("product.product_product_3") + + self.partner = self.partner_model.create({"name": "Test Partner"}) + + def _create_picking( + self, picking_type_id, location_id, location_dest_id, origin=False + ): + picking = self.picking_model.create( + { + "picking_type_id": picking_type_id.id, + "location_id": location_id.id, + "location_dest_id": location_dest_id.id, + "scheduled_date": fields.Date.today(), + "priority": "1", + "origin": origin, + } + ) + return picking + + def test_01_check_correct_value(self): + """ + Check that the OUT transfer references to the IN transfer with the `origin + reference` field. + """ + self.picking_in = self._create_picking( + self.picking_type_in_id, self.location_suppliers, self.location_stock + ) + self.picking_out = self._create_picking( + self.picking_type_out_id, + self.location_stock, + self.location_customers, + origin=self.picking_in.name, + ) + self.assertEqual(self.picking_out.origin, self.picking_in.name) + self.assertEqual( + self.picking_out.origin_reference, + self.picking_in, + "The " "Origin Reference should point to the IN transfer.", + ) diff --git a/stock_picking_origin_reference/views/stock_picking_views.xml b/stock_picking_origin_reference/views/stock_picking_views.xml new file mode 100644 index 000000000000..608f891f94cc --- /dev/null +++ b/stock_picking_origin_reference/views/stock_picking_views.xml @@ -0,0 +1,16 @@ + + + + stock.picking.form - stock_picking_origin_reference + stock.picking + + + + + + + not origin or origin_reference + + + +