fix: validation check when no conversion_factor (#26219)

This commit is contained in:
Noah Jacob 2021-07-15 18:32:15 +05:30 committed by GitHub
parent c66277e06b
commit d8668f78f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -314,13 +314,16 @@ def update_included_uom_in_report(columns, result, include_uom, conversion_facto
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 @@ def is_reposting_item_valuation_in_progress():
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)
frappe.msgprint(_("Item valuation reposting in progress. Report might show incorrect item valuation."), alert=1)