From 5ad612683223e5a5b01d2a2cea929aaa4ff877a3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 11 May 2017 13:34:04 +0530 Subject: [PATCH] On saving of Accounts Settings, only save enabled warehouses (#8772) --- erpnext/accounts/doctype/account/account.py | 6 +++--- .../doctype/accounts_settings/accounts_settings.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 998fee9732..189d37754f 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -188,9 +188,9 @@ class Account(Document): account_balance = get_balance_on(self.name) if account_balance != stock_balance: - frappe.throw(_('Account balance ({0}) and stock value ({1}) must be same')\ - .format(fmt_money(account_balance, currency=self.account_currency), - fmt_money(stock_balance, currency=self.account_currency))) + frappe.throw(_('Account balance ({0}) for {1} and stock value ({2}) for warehouse {3} must be same') + .format(fmt_money(account_balance, currency=self.account_currency), self.name, + fmt_money(stock_balance, currency=self.account_currency), self.warehouse)) elif self.warehouse: self.warehouse = None diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 5f569a8305..52e1b63871 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -21,10 +21,13 @@ class AccountsSettings(Document): company.save() # Create account head for warehouses - warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1) + warehouse_list = frappe.db.sql("""select name, company from tabWarehouse + where disabled=0""", as_dict=1) warehouse_with_no_company = [d.name for d in warehouse_list if not d.company] if warehouse_with_no_company: - frappe.throw(_("Company is missing in warehouses {0}").format(comma_and(warehouse_with_no_company))) + frappe.throw(_("Company is missing in warehouses {0}") + .format(comma_and(warehouse_with_no_company))) + for wh in warehouse_list: wh_doc = frappe.get_doc("Warehouse", wh.name) wh_doc.flags.ignore_permissions = True