fix: Add product ID check to prevent quantity adjustment errors on move lines without a product.
This commit is contained in:
parent
9d6044dd49
commit
b484493645
@ -164,6 +164,8 @@ class MrpProduction(models.Model):
|
|||||||
# Only auto-fix if it's a microscopic rounding drift (not a user overriding quantity intentionally)
|
# Only auto-fix if it's a microscopic rounding drift (not a user overriding quantity intentionally)
|
||||||
if 0.000001 < abs(diff) < (move.product_uom.rounding * 1.5):
|
if 0.000001 < abs(diff) < (move.product_uom.rounding * 1.5):
|
||||||
for ml in move.move_line_ids:
|
for ml in move.move_line_ids:
|
||||||
|
if not ml.product_id:
|
||||||
|
continue
|
||||||
# Safely apply the tiny difference to the first line that has enough quantity
|
# Safely apply the tiny difference to the first line that has enough quantity
|
||||||
if ml.quantity and ml.quantity + diff >= 0:
|
if ml.quantity and ml.quantity + diff >= 0:
|
||||||
ml.quantity += diff
|
ml.quantity += diff
|
||||||
@ -176,6 +178,8 @@ class MrpProduction(models.Model):
|
|||||||
diff = clean_total - total_done
|
diff = clean_total - total_done
|
||||||
if 0.000001 < abs(diff) < (move.product_uom.rounding * 1.5):
|
if 0.000001 < abs(diff) < (move.product_uom.rounding * 1.5):
|
||||||
for ml in move.move_line_ids:
|
for ml in move.move_line_ids:
|
||||||
|
if not ml.product_id:
|
||||||
|
continue
|
||||||
if ml.quantity and ml.quantity + diff >= 0:
|
if ml.quantity and ml.quantity + diff >= 0:
|
||||||
ml.quantity += diff
|
ml.quantity += diff
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user