[FIX] purchase: null stock_moves creation
Backport of 1f6ec2b8d6
When the quantity of a purchase order line is manually decreased and if
the purchase order line as been generated by more than one procurement.
If the new quantity is lower than the quantity of the smallest
procurement, it is impossible to validate the picking containg the
stock_moves created by the purchase order validation.
It is impossible to validate the picking, because it contains
stock_moves with 'product_qty' set to 0. Those stock_moves are generated
during the validation of a purchase order.
To fix this issue, we avoid the creation of stock moves with a
'product_qty' set to 0 which has no sense.
opw:708099
This commit is contained in:
@@ -609,15 +609,16 @@ class PurchaseOrderLine(models.Model):
|
||||
diff_quantity = line.product_qty
|
||||
for procurement in line.procurement_ids:
|
||||
procurement_qty = procurement.product_uom._compute_qty_obj(procurement.product_uom, procurement.product_qty, line.product_uom)
|
||||
tmp = template.copy()
|
||||
tmp.update({
|
||||
'product_uom_qty': min(procurement_qty, diff_quantity),
|
||||
'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination
|
||||
'procurement_id': procurement.id,
|
||||
'propagate': procurement.rule_id.propagate,
|
||||
})
|
||||
done += moves.create(tmp)
|
||||
diff_quantity -= min(procurement_qty, diff_quantity)
|
||||
if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0:
|
||||
tmp = template.copy()
|
||||
tmp.update({
|
||||
'product_uom_qty': min(procurement_qty, diff_quantity),
|
||||
'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination
|
||||
'procurement_id': procurement.id,
|
||||
'propagate': procurement.rule_id.propagate,
|
||||
})
|
||||
done += moves.create(tmp)
|
||||
diff_quantity -= min(procurement_qty, diff_quantity)
|
||||
if float_compare(diff_quantity, 0.0, precision_rounding=line.product_uom.rounding) > 0:
|
||||
template['product_uom_qty'] = diff_quantity
|
||||
done += moves.create(template)
|
||||
|
||||
Reference in New Issue
Block a user