On saving of Accounts Settings, only save enabled warehouses (#8772)
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 998fee9..189d377 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -188,9 +188,9 @@
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 5f569a8..52e1b63 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
@@ -21,10 +21,13 @@
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