fix: validation check when no conversion_factor (#26219)
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 8a6a3a3..b57b2aa 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -314,13 +314,16 @@
for row_idx, row in enumerate(result):
data = row.items() if is_dict_obj else enumerate(row)
for key, value in data:
- if key not in convertible_columns or not conversion_factors[row_idx-1]:
+ if key not in convertible_columns:
continue
+ # If no conversion factor for the UOM, defaults to 1
+ if not conversion_factors[row_idx]:
+ conversion_factors[row_idx] = 1
if convertible_columns.get(key) == 'rate':
- new_value = flt(value) * conversion_factors[row_idx-1]
+ new_value = flt(value) * conversion_factors[row_idx]
else:
- new_value = flt(value) / conversion_factors[row_idx-1]
+ new_value = flt(value) / conversion_factors[row_idx]
if not is_dict_obj:
row.insert(key+1, new_value)
@@ -386,4 +389,4 @@
reposting_in_progress = frappe.db.exists("Repost Item Valuation",
{'docstatus': 1, 'status': ['in', ['Queued','In Progress']]})
if reposting_in_progress:
- frappe.msgprint(_("Item valuation reposting in progress. Report might show incorrect item valuation."), alert=1)
\ No newline at end of file
+ frappe.msgprint(_("Item valuation reposting in progress. Report might show incorrect item valuation."), alert=1)