diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 9532a54087..cd33a076d0 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -362,13 +362,15 @@ cur_frm.set_query("income_account", "entries", function(doc) { }) // expense account -cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", - "company": doc.company +if (sys_defaults.auto_inventory_accounting) { + cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "Yes", + "debit_or_credit": "Debit", + "company": doc.company + } } } } diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js index 5e78b79cd8..4682724532 100644 --- a/setup/doctype/company/company.js +++ b/setup/doctype/company/company.js @@ -63,49 +63,50 @@ cur_frm.fields_dict.payables_group.get_query = function(doc) { return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50'; } - -cur_frm.fields_dict["stock_in_hand_account"].get_query = function(doc) { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "No", - "debit_or_credit": "Debit", - "company": doc.name +if (sys_defaults.auto_inventory_accounting) { + cur_frm.fields_dict["stock_in_hand_account"].get_query = function(doc) { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "No", + "debit_or_credit": "Debit", + "company": doc.name + } } } -} -cur_frm.fields_dict["stock_adjustment_account"].get_query = function(doc) { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", - "company": doc.name + cur_frm.fields_dict["stock_adjustment_account"].get_query = function(doc) { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "Yes", + "debit_or_credit": "Debit", + "company": doc.name + } } } -} -cur_frm.fields_dict["expenses_included_in_valuation"].get_query = - cur_frm.fields_dict["stock_adjustment_account"].get_query; + cur_frm.fields_dict["expenses_included_in_valuation"].get_query = + cur_frm.fields_dict["stock_adjustment_account"].get_query; -cur_frm.fields_dict["stock_delivered_but_not_billed"].get_query = - cur_frm.fields_dict["stock_in_hand_account"].get_query; + cur_frm.fields_dict["stock_delivered_but_not_billed"].get_query = + cur_frm.fields_dict["stock_in_hand_account"].get_query; -cur_frm.fields_dict["stock_received_but_not_billed"].get_query = function(doc) { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "No", - "debit_or_credit": "Credit", - "company": doc.name + cur_frm.fields_dict["stock_received_but_not_billed"].get_query = function(doc) { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "No", + "debit_or_credit": "Credit", + "company": doc.name + } } } -} -cur_frm.fields_dict["stock_adjustment_cost_center"].get_query = function(doc) { - return { - "query": "accounts.utils.get_cost_center_list", - "filters": {"company": doc.name} + cur_frm.fields_dict["stock_adjustment_cost_center"].get_query = function(doc) { + return { + "query": "accounts.utils.get_cost_center_list", + "filters": {"company": doc.name} + } } } \ No newline at end of file diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 61df6b0464..4589024d72 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -310,33 +310,36 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { } } -cur_frm.cscript.expense_account = function(doc, cdt, cdn){ - var d = locals[cdt][cdn]; - if(d.expense_account) { - var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype); - for(var i = 0; i < cl.length; i++){ - if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; +if (sys_defaults.auto_inventory_accounting) { + + cur_frm.cscript.expense_account = function(doc, cdt, cdn){ + var d = locals[cdt][cdn]; + if(d.expense_account) { + var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype); + for(var i = 0; i < cl.length; i++){ + if(!cl[i].expense_account) cl[i].expense_account = d.expense_account; + } + } + refresh_field(cur_frm.cscript.fname); + } + + // expense account + cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "Yes", + "debit_or_credit": "Debit", + "company": doc.company + } } } - refresh_field(cur_frm.cscript.fname); -} -// expense account -cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", - "company": doc.company + // cost center + cur_frm.fields_dict.delivery_note_details.grid.get_field("cost_center").get_query = function(doc) { + return { + query: "accounts.utils.get_cost_center_list", + filters: { company_name: doc.company} } } -} - -// cost center -cur_frm.fields_dict.delivery_note_details.grid.get_field("cost_center").get_query = function(doc) { - return { - query: "accounts.utils.get_cost_center_list", - filters: { company_name: doc.company} - } } \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 3e21207eaa..1f4aafa9e5 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -77,7 +77,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }; if (sys_defaults.auto_inventory_accounting) { - this.frm.add_fetch("company", "expense_adjustment_account", "stock_adjustment_account"); + this.frm.add_fetch("company", "stock_adjustment_account", "expense_adjustment_account"); this.frm.fields_dict["expense_adjustment_account"].get_query = function() { return { diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js index 3938661eaf..cf6821ebd5 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -41,16 +41,17 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ setup: function() { var me = this; + if (sys_defaults.auto_inventory_accounting) { + this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); - this.frm.add_fetch("company", "expense_account", "stock_adjustment_account"); - - this.frm.fields_dict["expense_account"].get_query = function() { - return { - "query": "accounts.utils.get_account_list", - "filters": { - "is_pl_account": "Yes", - "debit_or_credit": "Debit", - "company": me.frm.doc.company + this.frm.fields_dict["expense_account"].get_query = function() { + return { + "query": "accounts.utils.get_account_list", + "filters": { + "is_pl_account": "Yes", + "debit_or_credit": "Debit", + "company": me.frm.doc.company + } } } }