diff --git a/setup/stock_quant_reservation_info/odoo/addons/stock_quant_reservation_info b/setup/stock_quant_reservation_info/odoo/addons/stock_quant_reservation_info new file mode 120000 index 000000000..f7b51d5da --- /dev/null +++ b/setup/stock_quant_reservation_info/odoo/addons/stock_quant_reservation_info @@ -0,0 +1 @@ +../../../../stock_quant_reservation_info \ No newline at end of file diff --git a/setup/stock_quant_reservation_info/setup.py b/setup/stock_quant_reservation_info/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_quant_reservation_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_quant_reservation_info/README.rst b/stock_quant_reservation_info/README.rst new file mode 100644 index 000000000..b32ee7dd4 --- /dev/null +++ b/stock_quant_reservation_info/README.rst @@ -0,0 +1,78 @@ +=========================== +Stock Move Reservation Info +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_quant_reservation_info + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_quant_reservation_info + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to look which pickings, manufacture orders, etc. are reserving the products and check the following source. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to one product and check the quantity on hand, on that view you can see the quantity reserved and the button next to this field allows to see the pickings related to reservations. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +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/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_quant_reservation_info/__init__.py b/stock_quant_reservation_info/__init__.py new file mode 100644 index 000000000..4b76c7b2d --- /dev/null +++ b/stock_quant_reservation_info/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/stock_quant_reservation_info/__manifest__.py b/stock_quant_reservation_info/__manifest__.py new file mode 100644 index 000000000..fc44f4fce --- /dev/null +++ b/stock_quant_reservation_info/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2023 ForgeFlow S.L. +# (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Stock Move Reservation Info", + "summary": "Allows to see the reserved info of Products", + "version": "13.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Generic", + "depends": ["stock"], + "license": "AGPL-3", + "data": ["views/stock_quant.xml", "views/stock_move_line.xml"], + "installable": True, +} diff --git a/stock_quant_reservation_info/i18n/stock_quant_reservation_info.pot b/stock_quant_reservation_info/i18n/stock_quant_reservation_info.pot new file mode 100644 index 000000000..6bdce2688 --- /dev/null +++ b/stock_quant_reservation_info/i18n/stock_quant_reservation_info.pot @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_reservation_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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_quant_reservation_info +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_move_line__display_name +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_quant__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_quant_reservation_info +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_move_line__id +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_quant__id +msgid "ID" +msgstr "" + +#. module: stock_quant_reservation_info +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_move_line____last_update +#: model:ir.model.fields,field_description:stock_quant_reservation_info.field_stock_quant____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_quant_reservation_info +#: model:ir.model,name:stock_quant_reservation_info.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: stock_quant_reservation_info +#: model:ir.model,name:stock_quant_reservation_info.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_quant_reservation_info +#: model_terms:ir.ui.view,arch_db:stock_quant_reservation_info.view_stock_move_line_reserved_info_tree +msgid "Related Document" +msgstr "" + +#. module: stock_quant_reservation_info +#: model_terms:ir.ui.view,arch_db:stock_quant_reservation_info.view_stock_quant_tree_reserved_quantity +#: model_terms:ir.ui.view,arch_db:stock_quant_reservation_info.view_stock_quant_tree_reserved_quantity_editable +msgid "Reserved Moves" +msgstr "" + +#. module: stock_quant_reservation_info +#: code:addons/stock_quant_reservation_info/models/stock_quant.py:0 +#, python-format +msgid "Reserved moves for: " +msgstr "" diff --git a/stock_quant_reservation_info/models/__init__.py b/stock_quant_reservation_info/models/__init__.py new file mode 100644 index 000000000..cffdd8ca5 --- /dev/null +++ b/stock_quant_reservation_info/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_quant +from . import stock_move_line diff --git a/stock_quant_reservation_info/models/stock_move_line.py b/stock_quant_reservation_info/models/stock_move_line.py new file mode 100644 index 000000000..6f7dcebec --- /dev/null +++ b/stock_quant_reservation_info/models/stock_move_line.py @@ -0,0 +1,16 @@ +# Copyright 2023 ForgeFlow + +from odoo import models + + +class StockQuant(models.Model): + _inherit = "stock.move.line" + + def action_view_picking_from_reserved(self): + action = self.env["ir.actions.act_window"].for_xml_id( + "stock", "action_picking_tree_all" + ) + res = self.env.ref("stock.view_picking_form", False) + action["views"] = [(res and res.id or False, "form")] + action["res_id"] = self.picking_id.id + return action diff --git a/stock_quant_reservation_info/models/stock_quant.py b/stock_quant_reservation_info/models/stock_quant.py new file mode 100644 index 000000000..3d01429ae --- /dev/null +++ b/stock_quant_reservation_info/models/stock_quant.py @@ -0,0 +1,34 @@ +# Copyright 2023 ForgeFlow + +from odoo import _, models + + +class StockQuant(models.Model): + _inherit = "stock.quant" + + def action_reserved_moves(self): + self.ensure_one() + action = { + "name": _("Reserved moves for: " + self.product_id.name), + "view_mode": "list,form", + "res_model": "stock.move.line", + "views": [ + ( + self.env.ref( + "stock_quant_reservation_info.view_stock_move_line_reserved_info_tree" + ).id, + "list", + ), + (False, "form"), + ], + "type": "ir.actions.act_window", + "context": {}, + "domain": [ + ("product_id", "=", self.product_id.id), + ("product_uom_qty", ">", 0), + ("location_id.usage", "=", "internal"), + ("lot_id", "=", self.lot_id.id), + ("owner_id", "=", self.owner_id.id), + ], + } + return action diff --git a/stock_quant_reservation_info/readme/CONTRIBUTORS.rst b/stock_quant_reservation_info/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..fcd081018 --- /dev/null +++ b/stock_quant_reservation_info/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* David Jiménez diff --git a/stock_quant_reservation_info/readme/DESCRIPTION.rst b/stock_quant_reservation_info/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5ccbe26f3 --- /dev/null +++ b/stock_quant_reservation_info/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to look which pickings, manufacture orders, etc. are reserving the products and check the following source. diff --git a/stock_quant_reservation_info/readme/USAGE.rst b/stock_quant_reservation_info/readme/USAGE.rst new file mode 100644 index 000000000..130acbc55 --- /dev/null +++ b/stock_quant_reservation_info/readme/USAGE.rst @@ -0,0 +1 @@ +Go to one product and check the quantity on hand, on that view you can see the quantity reserved and the button next to this field allows to see the pickings related to reservations. diff --git a/stock_quant_reservation_info/static/description/icon.png b/stock_quant_reservation_info/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_quant_reservation_info/static/description/icon.png differ diff --git a/stock_quant_reservation_info/static/description/index.html b/stock_quant_reservation_info/static/description/index.html new file mode 100644 index 000000000..99ae212c8 --- /dev/null +++ b/stock_quant_reservation_info/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +Stock Move Reservation Info + + + +
+

Stock Move Reservation Info

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module allows to look which pickings, manufacture orders, etc. are reserving the products and check the following source.

+

Table of contents

+ +
+

Usage

+

Go to one product and check the quantity on hand, on that view you can see the quantity reserved and the button next to this field allows to see the pickings related to reservations.

+
+
+

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

+

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

+
+
+
+ + diff --git a/stock_quant_reservation_info/tests/__init__.py b/stock_quant_reservation_info/tests/__init__.py new file mode 100644 index 000000000..edf74904a --- /dev/null +++ b/stock_quant_reservation_info/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_quant_reservation_info diff --git a/stock_quant_reservation_info/tests/test_stock_quant_reservation_info.py b/stock_quant_reservation_info/tests/test_stock_quant_reservation_info.py new file mode 100644 index 000000000..0fbce5898 --- /dev/null +++ b/stock_quant_reservation_info/tests/test_stock_quant_reservation_info.py @@ -0,0 +1,89 @@ +# Copyright 2023 ForgeFlow S.L (https://www.forgeflow.com) + +from odoo.tests.common import TransactionCase + + +class TestStockQuantReservationInfo(TransactionCase): + def setUp(self): + super().setUp() + + self.partner = self.env["res.partner"].create({"name": "Jean"}) + self.partner_customer = self.env["res.partner"].create({"name": "Nate"}) + self.stock_location = self.env.ref("stock.stock_location_stock") + self.supplier_location = self.env.ref("stock.stock_location_suppliers") + self.customer_location = self.env.ref("stock.stock_location_customers") + uom_unit = self.env.ref("uom.product_uom_unit") + + self.product_1 = self.env["product.product"].create( + {"name": "Product 1", "type": "product", "uom_id": uom_unit.id} + ) + self.receipt = self.env["stock.picking"].create( + { + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "partner_id": self.partner.id, + "picking_type_id": self.env.ref("stock.picking_type_in").id, + } + ) + move_receipt_1 = self.env["stock.move"].create( + { + "name": "Test 1", + "product_id": self.product_1.id, + "quantity_done": 20, + "product_uom": self.product_1.uom_id.id, + "picking_id": self.receipt.id, + "picking_type_id": self.env.ref("stock.picking_type_in").id, + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + } + ) + move_receipt_1._action_confirm() + self.receipt.button_validate() + + def test_01_StockQuantReservationInfo(self): + + self.delivery = self.env["stock.picking"].create( + { + "location_id": self.stock_location.id, + "location_dest_id": self.customer_location.id, + "partner_id": self.partner_customer.id, + "picking_type_id": self.env.ref("stock.picking_type_out").id, + } + ) + customer_move = self.env["stock.move"].create( + { + "name": "move out", + "location_id": self.stock_location.id, + "location_dest_id": self.customer_location.id, + "product_id": self.product_1.id, + "product_uom": self.product_1.uom_id.id, + "product_uom_qty": 10.0, + "picking_id": self.delivery.id, + } + ) + customer_move._action_confirm() + + move_lines_ini = self.env["stock.move.line"].search( + [("picking_id", "=", self.delivery.id)] + ) + self.assertFalse(move_lines_ini) + self.assertEqual(self.product_1.stock_quant_ids[1].reserved_quantity, 0.0) + + self.delivery.action_assign() + + self.assertEqual(self.product_1.stock_quant_ids[1].reserved_quantity, 10.0) + + # we execute manually the method executed by the first button just to get the domain + action = self.product_1.stock_quant_ids[1].action_reserved_moves() + move_line_post_a = self.env["stock.move.line"].search(action["domain"]) + + # we execute manually the second button to see if the method + # returns the same stock picking form as the delivery picking + action2 = move_line_post_a.action_view_picking_from_reserved() + + self.assertEqual(action2["res_id"], self.delivery.id) + move_line_post_b = self.env["stock.move.line"].search( + [("picking_id", "=", self.delivery.id)] + ) + self.assertTrue(move_line_post_a) + self.assertEqual(move_line_post_a, move_line_post_b) diff --git a/stock_quant_reservation_info/views/stock_move_line.xml b/stock_quant_reservation_info/views/stock_move_line.xml new file mode 100644 index 000000000..0954ca63c --- /dev/null +++ b/stock_quant_reservation_info/views/stock_move_line.xml @@ -0,0 +1,23 @@ + + + stock.move.line.tree.reserved.info + stock.move.line + + + + +