From ef57e0eccc52e7c3681ec732cad6e7b40a39b2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Mart=C3=ADn?= Date: Wed, 9 Nov 2022 10:59:25 +0100 Subject: [PATCH] [14.0][IMP] stock_report_quantity_by_location: add virtual_available qty --- .../wizards/stock_report_quantity_by_location.py | 8 +++++++- .../wizards/stock_report_quantity_by_location_views.xml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location.py b/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location.py index df64085af..4f032f399 100644 --- a/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location.py +++ b/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location.py @@ -53,7 +53,11 @@ def _compute_stock_report_by_location(self): "quantity_unreserved": qty_unreserved, } mapping.setdefault(quant_group["product_id"][0], qty_dict) - products = self.env["product.product"].search([("type", "=", "product")]) + products = ( + self.env["product.product"] + .with_context(location=loc.id) + .search([("type", "=", "product")]) + ) vals_list = [] for product in products: qty_dict = mapping.get(product.id, {}) @@ -69,6 +73,7 @@ def _compute_stock_report_by_location(self): "quantity_on_hand": qty_on_hand, "quantity_reserved": qty_reserved, "quantity_unreserved": qty_unreserved, + "quantity_available": product.virtual_available, "location_id": loc.id, "wiz_id": self.id, "default_code": product.default_code, @@ -91,5 +96,6 @@ class StockReportQuantityByLocation(models.TransientModel): quantity_on_hand = fields.Float(string="Qty On Hand") quantity_reserved = fields.Float(string="Qty Reserved") quantity_unreserved = fields.Float(string="Qty Unreserved") + quantity_available = fields.Float(string="Qty Available") uom_id = fields.Many2one(comodel_name="uom.uom", string="Product UoM") default_code = fields.Char("Internal Reference") diff --git a/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location_views.xml b/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location_views.xml index aeddbf553..055d50b46 100644 --- a/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location_views.xml +++ b/stock_report_quantity_by_location/wizards/stock_report_quantity_by_location_views.xml @@ -60,6 +60,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + @@ -75,6 +76,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +