From 736f49baef76f6a6abb6c3e2eb2d96428a4e2faa Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 8 Oct 2018 15:26:02 +0000 Subject: [PATCH] [FIX] stock_account: float division by zero Steps to reproduce: - Create a stockable product P with 2 quantity on hand - Choose a delivery order in state 'done', unlock it and add a line with P - Try to set 2 as done quantity and confirm the wizard Bug: A ZeroDivisionError(float division by zero) was raised. opw:1886735 closes odoo/odoo#27547 --- addons/stock/models/stock_move_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 81fda382d91..e965ea28d0b 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -185,6 +185,8 @@ class StockMoveLine(models.Model): ml = super(StockMoveLine, self).create(vals) if ml.state == 'done': + if 'qty_done' in vals: + ml.move_id.product_uom_qty = ml.move_id.quantity_done if ml.product_id.type == 'product': Quant = self.env['stock.quant'] quantity = ml.product_uom_id._compute_quantity(ml.qty_done, ml.move_id.product_id.uom_id,rounding_method='HALF-UP')