From 19c84777d62e2ac4b621aaafe28fc5258a4ce770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Oct 2022 15:38:48 +0200 Subject: [PATCH] Update cost price of supplier moves When recomputing the cost price of drop shipment, we should also update the supplier moves. issue11724 review447281004 --- stock.py | 10 +++++----- tests/scenario_sale_supply_drop_shipment.rst | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/stock.py b/stock.py index 41b02cf183..c71c7242bf 100644 --- a/stock.py +++ b/stock.py @@ -551,11 +551,11 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): if qty: product_cost[product] = round_price(cost / qty) - for c_move in shipment.customer_moves: - cost_price = product_cost[c_move.product] - if cost_price != c_move.cost_price: - c_move.cost_price = cost_price - to_save.append(c_move) + for move in shipment.moves: + cost_price = product_cost[move.product] + if cost_price != move.cost_price: + move.cost_price = cost_price + to_save.append(move) if to_save: Move.save(to_save) diff --git a/tests/scenario_sale_supply_drop_shipment.rst b/tests/scenario_sale_supply_drop_shipment.rst index c7035e8a54..369544bdca 100644 --- a/tests/scenario_sale_supply_drop_shipment.rst +++ b/tests/scenario_sale_supply_drop_shipment.rst @@ -282,6 +282,9 @@ Receive purchase invoice at different price:: >>> shipment, = [s for s in purchase.drop_shipments ... if s.state == 'done'] + >>> move, = shipment.supplier_moves + >>> move.cost_price + Decimal('4.0000') >>> move, = shipment.customer_moves >>> move.cost_price Decimal('4.0000')