Update __init__.py

This commit is contained in:
Rushabh Mehta 2017-06-20 12:14:32 +05:30 committed by GitHub
parent e9ff1914fc
commit 777526e3a8

View File

@ -59,18 +59,10 @@ def is_perpetual_inventory_enabled(company):
company = "_Test Company" if frappe.flags.in_test else get_default_company() company = "_Test Company" if frappe.flags.in_test else get_default_company()
if not hasattr(frappe.local, 'enable_perpetual_inventory'): if not hasattr(frappe.local, 'enable_perpetual_inventory'):
perpetual_inventory = get_company_wise_perptual_inventory() frappe.local.enable_perpetual_inventory = {}
frappe.local.enable_perpetual_inventory = perpetual_inventory
if not frappe.local.enable_perpetual_inventory.get(company): if not company in frappe.local.enable_perpetual_inventory:
is_enabled = frappe.db.get_value("Company", company, "enable_perpetual_inventory") or 0 frappe.local.enable_perpetual_inventory[company] = frappe.db.get_value("Company",
frappe.local.enable_perpetual_inventory.setdefault(company, is_enabled) company, "enable_perpetual_inventory") or 0
return frappe.local.enable_perpetual_inventory.get(company) return frappe.local.enable_perpetual_inventory[company]
def get_company_wise_perptual_inventory():
company_dict = {}
for data in frappe.get_all('Company', fields = ["name", "enable_perpetual_inventory"]):
company_dict[data.name] = data.enable_perpetual_inventory
return company_dict