Skip to content

Commit

Permalink
fix: validation check when no conversion_factor (#26527)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahjacob authored Jul 16, 2021
1 parent 627a8a8 commit 3362c08
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions erpnext/stock/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit 3362c08

Please sign in to comment.