From a6c8e8747aae7da4e5065270ea82515277ef753b Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 24 Jun 2025 14:02:26 +0200 Subject: [PATCH] [IMP] shopfloor: Add context key to control package total quantity computation the total quantity per package is not relevant or displayed in all scenarios where the parser is used. currently, it's only used in the zone_picking scenario this PR introduces a context key to conditionally disable the total quantity computation based on the use case. this avoids unnecessary access to stock.quant when the information isn't required, improving performance and preventing potential concurrency issues --- shopfloor/actions/data.py | 4 +++- shopfloor/services/cluster_picking.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shopfloor/actions/data.py b/shopfloor/actions/data.py index 47e10453ba4..441405156f6 100644 --- a/shopfloor/actions/data.py +++ b/shopfloor/actions/data.py @@ -131,7 +131,9 @@ def _package_parser(self): ("package_type_id:storage_type", ["id", "name"]), ( "quant_ids:total_quantity", - lambda rec, fname: sum(rec.quant_ids.mapped("quantity")), + lambda rec, fname: 0 + if rec.env.context.get("no_quantity", False) + else sum(rec.quant_ids.mapped("quantity")), ), ] diff --git a/shopfloor/services/cluster_picking.py b/shopfloor/services/cluster_picking.py index d54ef12b9f6..cf2c78a88c8 100644 --- a/shopfloor/services/cluster_picking.py +++ b/shopfloor/services/cluster_picking.py @@ -115,7 +115,7 @@ def _response_for_scan_destination(self, move_line, message=None, qty_done=None) # suggest pack to be used for the next line data["package_dest"] = self.data.package( last_picked_line.result_package_id.with_context( - picking_id=move_line.picking_id.id + picking_id=move_line.picking_id.id, no_quantity=True ), picking=move_line.picking_id, )