[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
This commit is contained in:
Goffin Simon
2018-10-09 07:45:59 +00:00
parent 798d21ee3f
commit 736f49baef
+2
View File
@@ -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')