fix: Set Expense account from warehouse only if warehouse exists
This commit is contained in:
parent
cd12d95a24
commit
5c82af50f9
@ -246,7 +246,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
and (not item.po_detail or
|
and (not item.po_detail or
|
||||||
not frappe.db.get_value("Purchase Order Item", item.po_detail, "delivered_by_supplier")):
|
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"]:
|
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(
|
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))
|
item.idx, frappe.bold(warehouse_account[item.warehouse]["account"]), frappe.bold(item.expense_account), frappe.bold(item.warehouse))
|
||||||
@ -657,7 +657,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
)
|
)
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": self.get_company_default("exchange_gain_loss_account"),
|
"account": self.get_company_default("exchange_gain_loss_account"),
|
||||||
"against": self.supplier,
|
"against": self.supplier,
|
||||||
"credit": discrepancy_caused_by_exchange_rate_difference,
|
"credit": discrepancy_caused_by_exchange_rate_difference,
|
||||||
"cost_center": item.cost_center,
|
"cost_center": item.cost_center,
|
||||||
@ -1193,7 +1193,7 @@ def get_purchase_document_details(doc):
|
|||||||
purchase_receipts_or_invoices.append(item.get(doc_reference))
|
purchase_receipts_or_invoices.append(item.get(doc_reference))
|
||||||
if item.get(items_reference):
|
if item.get(items_reference):
|
||||||
items.append(item.get(items_reference))
|
items.append(item.get(items_reference))
|
||||||
|
|
||||||
exchange_rate_map = frappe._dict(frappe.get_all(parent_doctype, filters={'name': ('in',
|
exchange_rate_map = frappe._dict(frappe.get_all(parent_doctype, filters={'name': ('in',
|
||||||
purchase_receipts_or_invoices)}, fields=['name', 'conversion_rate'], as_list=1))
|
purchase_receipts_or_invoices)}, fields=['name', 'conversion_rate'], as_list=1))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user