diff --git a/erpnext/__init__.py b/erpnext/__init__.py index e1e355397f..6f73467ced 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -62,7 +62,7 @@ def is_perpetual_inventory_enabled(company): frappe.local.enable_perpetual_inventory = {} if not company in frappe.local.enable_perpetual_inventory: - frappe.local.enable_perpetual_inventory[company] = frappe.db.get_value("Company", + frappe.local.enable_perpetual_inventory[company] = frappe.db.get_value("Company", company, "enable_perpetual_inventory") or 0 return frappe.local.enable_perpetual_inventory[company] diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index f7e4c25885..1af0d8cf1a 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -89,6 +89,10 @@ class Company(Document): if self.default_currency: frappe.db.set_value("Currency", self.default_currency, "enabled", 1) + if hasattr(frappe.local, 'enable_perpetual_inventory') and \ + self.name in frappe.local.enable_perpetual_inventory: + frappe.local.enable_perpetual_inventory[self.name] = self.enable_perpetual_inventory + frappe.clear_cache() def install_country_fixtures(self): diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index a38b222d89..19cc44a119 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -62,7 +62,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend this._super(); if(this.frm.doc.docstatus===1) { this.show_stock_ledger(); - if (erpnext.is_perpetual_inventory_enabled(doc.company)) { + if (erpnext.is_perpetual_inventory_enabled(this.frm.doc.company)) { this.show_general_ledger(); } }