From db2ac23a7218da87ac645b33cb22f68ca07c4247 Mon Sep 17 00:00:00 2001 From: DavidJForgeFlow Date: Thu, 29 Sep 2022 17:14:09 +0200 Subject: [PATCH 01/26] [14.0][ADD] stock_quant_reservation_info --- stock_quant_reservation_info/README.rst | 0 stock_quant_reservation_info/__init__.py | 3 ++ stock_quant_reservation_info/__manifest__.py | 16 ++++++++ .../models/__init__.py | 2 + .../models/stock_move_line.py | 16 ++++++++ .../models/stock_quant.py | 31 +++++++++++++++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 1 + stock_quant_reservation_info/readme/USAGE.rst | 1 + .../views/stock_move_line.xml | 22 +++++++++++ .../views/stock_quant.xml | 39 +++++++++++++++++++ 11 files changed, 132 insertions(+) create mode 100644 stock_quant_reservation_info/README.rst create mode 100644 stock_quant_reservation_info/__init__.py create mode 100644 stock_quant_reservation_info/__manifest__.py create mode 100644 stock_quant_reservation_info/models/__init__.py create mode 100644 stock_quant_reservation_info/models/stock_move_line.py create mode 100644 stock_quant_reservation_info/models/stock_quant.py create mode 100644 stock_quant_reservation_info/readme/CONTRIBUTORS.rst create mode 100644 stock_quant_reservation_info/readme/DESCRIPTION.rst create mode 100644 stock_quant_reservation_info/readme/USAGE.rst create mode 100644 stock_quant_reservation_info/views/stock_move_line.xml create mode 100644 stock_quant_reservation_info/views/stock_quant.xml diff --git a/stock_quant_reservation_info/README.rst b/stock_quant_reservation_info/README.rst new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stock_quant_reservation_info/__init__.py b/stock_quant_reservation_info/__init__.py new file mode 100644 index 000000000000..4b76c7b2d5c9 --- /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 000000000000..ef07e3873a24 --- /dev/null +++ b/stock_quant_reservation_info/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2019-2020 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": "14.0.1.0.3", + "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/models/__init__.py b/stock_quant_reservation_info/models/__init__.py new file mode 100644 index 000000000000..cffdd8ca504d --- /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 000000000000..bb36805e1f06 --- /dev/null +++ b/stock_quant_reservation_info/models/stock_move_line.py @@ -0,0 +1,16 @@ +# Copyright 2022 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 000000000000..f836df0bb8da --- /dev/null +++ b/stock_quant_reservation_info/models/stock_quant.py @@ -0,0 +1,31 @@ +# Copyright 2022 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), + ], + } + 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 000000000000..fcd08101846c --- /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 000000000000..5ccbe26f38d6 --- /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 000000000000..130acbc550b2 --- /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/views/stock_move_line.xml b/stock_quant_reservation_info/views/stock_move_line.xml new file mode 100644 index 000000000000..f0a7ed517c4f --- /dev/null +++ b/stock_quant_reservation_info/views/stock_move_line.xml @@ -0,0 +1,22 @@ + + + stock.move.line.tree.reserved.info + stock.move.line + + + + +