diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js index 4a66c3c3f9e..1847864ff18 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -30,6 +30,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ var me = this; if (sys_defaults.perpetual_accounting) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); + this.frm.add_fetch("company", "cost_center", "cost_center"); this.frm.fields_dict["expense_account"].get_query = function() { return { diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index c91344f62fb..52542ebe0d1 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -17,6 +17,7 @@ class DocType(StockController): def validate(self): self.validate_data() + self.validate_expense_account() def on_submit(self): self.insert_stock_ledger_entries() @@ -299,12 +300,7 @@ class DocType(StockController): def make_gl_entries(self): if not cint(webnotes.defaults.get_global_default("perpetual_accounting")): return - - if not self.doc.expense_account: - msgprint(_("Please enter Expense Account"), raise_exception=1) - else: - self.validate_expense_account() - + if not self.doc.cost_center: msgprint(_("Please enter Cost Center"), raise_exception=1) @@ -327,13 +323,19 @@ class DocType(StockController): self.sync_stock_account_balance(warehouse_list, self.doc.cost_center) def validate_expense_account(self): - if not webnotes.conn.sql("select * from `tabStock Ledger Entry`"): + if not cint(webnotes.defaults.get_global_default("perpetual_accounting")): + return + + if not self.doc.expense_account: + msgprint(_("Please enter Expense Account"), raise_exception=1) + elif not webnotes.conn.sql("""select * from `tabStock Ledger Entry` + where ifnull(is_cancelled, 'No') = 'No'"""): if webnotes.conn.get_value("Account", self.doc.expense_account, "is_pl_account") == "Yes": msgprint(_("""Expense Account can not be a PL Account, as this stock \ - reconciliation is an opening entry. Please select 'Temporary Liability' or \ - relevant account"""), raise_exception=1) - + reconciliation is an opening entry. \ + Please select 'Temporary Account (Liabilities)' or relevant account"""), + raise_exception=1) @webnotes.whitelist() def upload(): diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt index a00547c5b31..2891ad260a0 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.txt +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-28 10:35:31", "docstatus": 0, - "modified": "2013-08-07 11:14:17", + "modified": "2013-08-07 18:16:18", "modified_by": "Administrator", "owner": "Administrator" }, @@ -109,6 +109,13 @@ "label": "Expense Account", "options": "Account" }, + { + "doctype": "DocField", + "fieldname": "cost_center", + "fieldtype": "Link", + "label": "Cost Center", + "options": "Cost Center" + }, { "doctype": "DocField", "fieldname": "col1",