Merge pull request #3988 from nabinhait/fix2
Set expense account in stock reco only if company available
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 4b67c0a..13e7e5b 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -36,20 +36,21 @@
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);
+ }
}
- }
- });
+ });
+ }
}
},