From fea1e8a24262c7f97af3c0fd471b7918e578c775 Mon Sep 17 00:00:00 2001 From: ADHOC - Bot Date: Tue, 25 Feb 2025 21:19:00 -0300 Subject: [PATCH] [FIX] sale_stock_ux: return quantity wizard --- sale_stock_ux/models/sale_order_line.py | 10 ++++++---- sale_stock_ux/models/stock_move.py | 4 ++++ sale_stock_ux/wizards/stock_return_picking.py | 5 +++++ sale_stock_ux/wizards/stock_return_picking_views.xml | 9 ++++----- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/sale_stock_ux/models/sale_order_line.py b/sale_stock_ux/models/sale_order_line.py index 6527ec9b8..1b052c1ff 100644 --- a/sale_stock_ux/models/sale_order_line.py +++ b/sale_stock_ux/models/sale_order_line.py @@ -63,7 +63,6 @@ def _compute_delivery_status(self): if line.order_id.force_delivery_status: line.delivery_status = line.order_id.force_delivery_status continue - if float_compare(line.all_qty_delivered, line.product_uom_qty, precision_digits=precision) == -1: delivery_status = "to deliver" elif float_compare(line.all_qty_delivered, line.product_uom_qty, precision_digits=precision) >= 0: @@ -140,7 +139,10 @@ def _compute_quantity_returned(self): if order_line.qty_delivered_method == "stock_move": return_moves = order_line.mapped("move_ids").filtered( lambda r: ( - r.state == "done" and not r.scrapped and r.location_dest_id.usage != "customer" and r.to_refund + r.state == "done" + and not r.scrapped + and r.location_dest_id.usage != "customer" + and not r.to_redeliver ) ) for move in return_moves: @@ -181,8 +183,8 @@ def _compute_quantity_returned(self): continue filters = { "outgoing_moves": lambda m: m.location_dest_id.usage == "customer" - and (not m.origin_returned_move_id or (m.origin_returned_move_id and m.to_refund)), - "incoming_moves": lambda m: m.location_dest_id.usage != "customer" and m.to_refund, + and (not m.origin_returned_move_id or (m.origin_returned_move_id and not m.to_redeliver)), + "incoming_moves": lambda m: m.location_dest_id.usage != "customer" and not m.to_redeliver, } order_qty = order_line.product_uom._compute_quantity( order_line.product_uom_qty, relevant_bom.product_uom_id diff --git a/sale_stock_ux/models/stock_move.py b/sale_stock_ux/models/stock_move.py index 8a3c6a0a2..d2356afbb 100644 --- a/sale_stock_ux/models/stock_move.py +++ b/sale_stock_ux/models/stock_move.py @@ -12,6 +12,10 @@ class StockMove(models.Model): related="group_id.sale_id", ) + to_redeliver = fields.Boolean( + default=False, help="If true, then the returned quantities on the SO line will not be imputed" + ) + def _get_new_picking_values(self): """return create values for new picking that will be linked with group of moves in self. diff --git a/sale_stock_ux/wizards/stock_return_picking.py b/sale_stock_ux/wizards/stock_return_picking.py index 06f82e686..2847b0c33 100644 --- a/sale_stock_ux/wizards/stock_return_picking.py +++ b/sale_stock_ux/wizards/stock_return_picking.py @@ -21,3 +21,8 @@ def default_get(self, fields): except KeyError: pass return result + + def action_create_exchanges(self): + action = super().action_create_exchanges() + self.picking_id.return_ids.move_ids.write({"to_redeliver": True}) + return action diff --git a/sale_stock_ux/wizards/stock_return_picking_views.xml b/sale_stock_ux/wizards/stock_return_picking_views.xml index b8bd6840e..d005df565 100644 --- a/sale_stock_ux/wizards/stock_return_picking_views.xml +++ b/sale_stock_ux/wizards/stock_return_picking_views.xml @@ -7,16 +7,15 @@ @@ -25,7 +24,7 @@ - Para Abonar (actualizar OC/OV) + 1