From f44128f81ca7a41f5498f860094de59c1dd987bb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 7 Sep 2015 10:45:15 +0530 Subject: [PATCH] Set expense account in stock reco only if company available --- .../stock_reconciliation.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index 4b67c0a4b6..13e7e5b479 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -36,20 +36,21 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ set_default_expense_account: function() { var me = this; - - if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) { - return this.frm.call({ - method: "erpnext.accounts.utils.get_company_default", - args: { - "fieldname": "stock_adjustment_account", - "company": this.frm.doc.company - }, - callback: function(r) { - if (!r.exc) { - me.frm.set_value("expense_account", r.message); + if(this.frm.doc.company) { + if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) { + return this.frm.call({ + method: "erpnext.accounts.utils.get_company_default", + args: { + "fieldname": "stock_adjustment_account", + "company": this.frm.doc.company + }, + callback: function(r) { + if (!r.exc) { + me.frm.set_value("expense_account", r.message); + } } - } - }); + }); + } } },