mirror of
https://github.com/frappe/erpnext.git
synced 2026-10-31 23:07:51 +00:00
fix(stock): scale disassembly tolerance by the source conversion factor
The row's conversion factor is editable, so a large one widened the tolerance without limit.
(cherry picked from commit a890c77fa0)
This commit is contained in:
@@ -1103,7 +1103,7 @@ class StockEntry(StockController):
|
||||
expected_by_name, expected_by_item = {}, defaultdict(float)
|
||||
for source_row, qty in expected_rows:
|
||||
if source_row.get("name"):
|
||||
expected_by_name[source_row.name] = qty
|
||||
expected_by_name[source_row.name] = (qty, flt(source_row.conversion_factor))
|
||||
expected_by_item[source_row.item_code] += qty
|
||||
|
||||
precision = frappe.get_precision("Stock Entry Detail", "transfer_qty")
|
||||
@@ -1116,9 +1116,9 @@ class StockEntry(StockController):
|
||||
continue # covered by validate_finished_good_consumption
|
||||
|
||||
if row.ste_detail and row.ste_detail in expected_by_name:
|
||||
expected = expected_by_name[row.ste_detail]
|
||||
expected, conversion_factor = expected_by_name[row.ste_detail]
|
||||
elif row.item_code in expected_by_item:
|
||||
expected = expected_by_item[row.item_code]
|
||||
expected, conversion_factor = expected_by_item[row.item_code], 1
|
||||
else:
|
||||
frappe.throw(
|
||||
_(
|
||||
@@ -1128,8 +1128,8 @@ class StockEntry(StockController):
|
||||
title=_("Invalid Disassembly Item"),
|
||||
)
|
||||
|
||||
# qty is rounded in the row UOM, so allow that rounding scaled to stock UOM
|
||||
row_tolerance = max(tolerance, qty_tolerance * flt(row.conversion_factor))
|
||||
# qty is rounded in the source UOM, so allow that rounding scaled to stock UOM
|
||||
row_tolerance = max(tolerance, qty_tolerance * conversion_factor)
|
||||
if abs(flt(row.transfer_qty, precision) - flt(expected, precision)) > row_tolerance:
|
||||
frappe.throw(
|
||||
_(
|
||||
|
||||
Reference in New Issue
Block a user