Fixed Asset Refactor Review fixes (#19666)

* fix: fixed asset item creation ux fixes

* fix: auto creation of asset ux fixes

* fix: [LCV] incorrect condition when checking assets linked with PR

* fix: bulk update assets

* refac: remove company level cwip enabling
* cwip can be enabled only on category level

* fix: #19649
This commit is contained in:
Saqib
2019-11-22 16:32:34 +05:30
committed by Nabin Hait
parent b5c296da9e
commit 1919af2ff1
13 changed files with 562 additions and 567 deletions

View File

@@ -7,15 +7,11 @@ def execute():
'''Get 'Disable CWIP Accounting value' from Asset Settings, set it in 'Enable Capital Work in Progress Accounting' field
in Company, delete Asset Settings '''
if frappe.db.exists("DocType","Asset Settings"):
frappe.reload_doctype("Company")
cwip_value = frappe.db.get_single_value("Asset Settings","disable_cwip_accounting")
if frappe.db.exists("DocType", "Asset Settings"):
frappe.reload_doctype("Asset Category")
cwip_value = frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting")
frappe.db.sql("""UPDATE `tabAsset Category` SET enable_cwip_accounting = %s""", cint(cwip_value))
companies = [x['name'] for x in frappe.get_all("Company", "name")]
for company in companies:
enable_cwip_accounting = cint(not cint(cwip_value))
frappe.db.set_value("Company", company, "enable_cwip_accounting", enable_cwip_accounting)
frappe.db.sql(
""" DELETE FROM `tabSingles` where doctype = 'Asset Settings' """)
frappe.delete_doc_if_exists("DocType","Asset Settings")
frappe.db.sql("""DELETE FROM `tabSingles` where doctype = 'Asset Settings'""")
frappe.delete_doc_if_exists("DocType", "Asset Settings")