feat: Disable CWIP Accounting checkbox added in Company and Asset Category (#19262)

* feat: Disable CWIP Accounting checkbox added in Company and Asset Category

Asset Settings is removed completely
Disable CWIP Accounting checkbox will give priority to Asset Category

* fix: Changed checkbox name to 'Enable Capital Work in Progress Accounting'

- checkbox will be disabled by default
- Enabling it in Company will globally enable it
- When globally disabled , it's value on the asset category will be considered

* chore: Added patch to set pre-existing CWIP checkbox value into new checkbox

* fix(test): Asset

* fix: Asset Test and Patch

* fix(test): Opening Invoice Creation Tool

* Update asset.py

* fix: Patch and other fixes
This commit is contained in:
Marica
2019-11-12 19:17:43 +05:30
committed by Nabin Hait
parent 010714757c
commit d00c59830e
19 changed files with 723 additions and 1021 deletions

View File

@@ -0,0 +1,22 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cint
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.sql(""" SELECT value FROM `tabSingles` WHERE doctype='Asset Settings'
and field='disable_cwip_accounting' """, as_dict=1)
companies = [x['name'] for x in frappe.get_all("Company", "name")]
for company in companies:
enable_cwip_accounting = cint(not cint(cwip_value[0]['value']))
frappe.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")