diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index 7ba1144f46c..829d15ac0d5 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -45,7 +45,7 @@ class StockMove(models.Model): precision = self.env['decimal.precision'].precision_get('Product Price') # If the move is a return, use the original move's price unit. if self.origin_returned_move_id and self.origin_returned_move_id.sudo().stock_valuation_layer_ids: - price_unit = self.origin_returned_move_id.sudo().stock_valuation_layer_ids[-1].unit_cost + return self.origin_returned_move_id.sudo().stock_valuation_layer_ids[-1].unit_cost return price_unit if not float_is_zero(price_unit, precision) or self._should_force_price_unit() else self.product_id.standard_price @api.model diff --git a/addons/stock_account/tests/test_stockvaluationlayer.py b/addons/stock_account/tests/test_stockvaluationlayer.py index eb095226613..871c75a7bf6 100644 --- a/addons/stock_account/tests/test_stockvaluationlayer.py +++ b/addons/stock_account/tests/test_stockvaluationlayer.py @@ -678,6 +678,17 @@ class TestStockValuationFIFO(TestStockValuationCommon): self.assertEqual(self.product1.quantity_svl, 2) self.assertAlmostEqual(self.product1.standard_price, 10) + def test_return_delivery_2(self): + self._make_in_move(self.product1, 1, unit_cost=10) + self.product1.standard_price = 0 + self._make_in_move(self.product1, 1, unit_cost=0) + + self._make_out_move(self.product1, 1) + out_move02 = self._make_out_move(self.product1, 1, create_picking=True) + + returned = self._make_return(out_move02, 1) + self.assertEqual(returned.stock_valuation_layer_ids.value, 0) + class TestStockValuationChangeCostMethod(TestStockValuationCommon): def test_standard_to_fifo_1(self):