fix: Conversion factor error for invoices without item code (petty expenses) (#32714)

* fix: Set default uom conversion factor to 1 for invoices

* chore: set default conversion_factor as 1

* chore: remove print statements
This commit is contained in:
Deepesh Garg 2022-12-29 10:41:36 +05:30 committed by GitHub
parent 123920d0bc
commit 617518389a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -890,7 +890,7 @@
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2022-11-02 12:53:12.693217", "modified": "2022-12-28 16:17:33.484531",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice Item", "name": "Sales Invoice Item",

View File

@ -584,7 +584,12 @@ class AccountsController(TransactionBase):
if bool(uom) != bool(stock_uom): # xor if bool(uom) != bool(stock_uom): # xor
item.stock_uom = item.uom = uom or stock_uom item.stock_uom = item.uom = uom or stock_uom
item.conversion_factor = get_uom_conv_factor(item.get("uom"), item.get("stock_uom")) # UOM cannot be zero so substitute as 1
item.conversion_factor = (
get_uom_conv_factor(item.get("uom"), item.get("stock_uom"))
or item.get("conversion_factor")
or 1
)
if self.doctype == "Purchase Invoice": if self.doctype == "Purchase Invoice":
self.set_expense_account(for_validate) self.set_expense_account(for_validate)