diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index 1fc9f202fed..43a7c5dd48f 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -316,13 +316,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) @@ -370,4 +373,4 @@ def add_additional_uom_columns(columns, result, include_uom, conversion_factors) else: row[data.converted_col] = flt(value_before_conversion) / conversion_factor - result[row_idx] = row \ No newline at end of file + result[row_idx] = row