From ca269fcb057890f230f0e404070bfebe141e3722 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 5 Aug 2024 10:36:23 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20sale=5Forder=5Fline=5Fplanned=5Fquantit?= =?UTF-8?q?y:=20Calcular=20diferencia=20solo=20a=20mvtos=20con=20tipo=20op?= =?UTF-8?q?eraci=C3=B3n=20marcada.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/sale_order_line.py | 32 +++++++++++++------ .../views/sale_order_view.xml | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/sale_order_line_planned_quantity/models/sale_order_line.py b/sale_order_line_planned_quantity/models/sale_order_line.py index 01f12dfc..90a0f39f 100644 --- a/sale_order_line_planned_quantity/models/sale_order_line.py +++ b/sale_order_line_planned_quantity/models/sale_order_line.py @@ -32,15 +32,18 @@ class SaleOrderLine(models.Model): def _compute_planned_quantity(self): for line in self: planned_quantity = 0 + moves_planned_quantities = False if line.move_ids: - moves = line.move_ids.filtered( - lambda x: x.state != "cancel" - and x.picking_type_id - and x.picking_type_id.use_to_calculate_planned_quantities + moves_planned_quantities = line.move_ids.filtered( + lambda x: x.picking_type_id.use_to_calculate_planned_quantities ) - if moves: - planned_quantity = sum(moves.mapped("product_uom_qty")) - line.planned_quantity = planned_quantity + if moves_planned_quantities: + moves = moves_planned_quantities.filtered( + lambda x: x.state != "cancel" + ) + if moves: + planned_quantity = sum(moves.mapped("product_uom_qty")) + line.planned_quantity = planned_quantity if moves_planned_quantities else 0 @api.depends( "planned_quantity", @@ -49,6 +52,15 @@ def _compute_planned_quantity(self): ) def _compute_difference_between_ordered_planned(self): for line in self: - line.difference_between_ordered_planned = bool( - line.product_uom_qty != line.planned_quantity and line.state != "draft" - ) + moves_planned_quantities = False + if line.move_ids: + moves_planned_quantities = line.move_ids.filtered( + lambda x: x.picking_type_id.use_to_calculate_planned_quantities + ) + if moves_planned_quantities: + line.difference_between_ordered_planned = bool( + line.product_uom_qty != line.planned_quantity + and line.state != "draft" + ) + else: + line.difference_between_ordered_planned = False diff --git a/sale_order_line_planned_quantity/views/sale_order_view.xml b/sale_order_line_planned_quantity/views/sale_order_view.xml index fe923ed8..b65577fe 100644 --- a/sale_order_line_planned_quantity/views/sale_order_view.xml +++ b/sale_order_line_planned_quantity/views/sale_order_view.xml @@ -5,7 +5,7 @@