fix: Set Expense account from warehouse only if warehouse exists

This commit is contained in:
marination 2021-07-26 19:41:53 +05:30
parent cd12d95a24
commit 5c82af50f9

View File

@ -246,7 +246,7 @@ class PurchaseInvoice(BuyingController):
and (not item.po_detail or
not frappe.db.get_value("Purchase Order Item", item.po_detail, "delivered_by_supplier")):
if self.update_stock and (not item.from_warehouse):
if self.update_stock and item.warehouse and (not item.from_warehouse):
if for_validate and item.expense_account and item.expense_account != warehouse_account[item.warehouse]["account"]:
msg = _("Row {0}: Expense Head changed to {1} because account {2} is not linked to warehouse {3} or it is not the default inventory account").format(
item.idx, frappe.bold(warehouse_account[item.warehouse]["account"]), frappe.bold(item.expense_account), frappe.bold(item.warehouse))