From 2eb7bafdf6b455d5fb257bd11b6356791148d8a1 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Tue, 28 Jun 2022 13:47:16 +0000 Subject: [PATCH] [FIX] stock_account: correctly compute price_unit for return Current behavior: When returning a delivery that had a quanity lower than 1 the inventory valuation showed a value of 0 for the return Steps to reproduce: - Create a product that use "m" (meters) as UoM - Change the configuration of the product Category and set Costing method to FIFO and Inventory valuation to Automated - Create a SO for this product with a quantity of 0.15 - Validate the order and validate the delivery with full quantity - Now click on return and make a return for the delivery - Validate the return and go in the inventory valuation - Show the inventory valuation for the created product - The return has a value of 0 when it should have the same value as the delivery opw-2880153 closes odoo/odoo#94827 X-original-commit: 9bc3d5ebef234aa1d77f1d467746837a5cadc037 Signed-off-by: Adrien Widart Signed-off-by: Anh Thao PHAM --- addons/stock_account/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index 19de960e066..882d23c4bfb 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -47,7 +47,7 @@ class StockMove(models.Model): if self.origin_returned_move_id and self.origin_returned_move_id.sudo().stock_valuation_layer_ids: layers = self.origin_returned_move_id.sudo().stock_valuation_layer_ids quantity = sum(layers.mapped("quantity")) - return layers.currency_id.round(sum(layers.mapped("value")) / quantity) if not float_is_zero(quantity, layers.uom_id.rounding) else 0 + return layers.currency_id.round(sum(layers.mapped("value")) / quantity) if not float_is_zero(quantity, precision_rounding=layers.uom_id.rounding) else 0 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