fix SC accounts validation error; delete default HRMS leave types on setup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b91ff07f56
commit
0699beb3ba
|
|
@ -18,13 +18,15 @@ LEAVE_TYPES_JSON = os.path.join(
|
|||
|
||||
HRMS_DEFAULT_COMPONENTS = ["Basic", "Arrear", "Leave Encashment", "Income Tax"]
|
||||
|
||||
HRMS_DEFAULT_LEAVE_TYPES = [
|
||||
"Casual Leave", "Compensatory Off", "Sick Leave", "Privilege Leave", "Leave Without Pay"
|
||||
]
|
||||
|
||||
|
||||
def create_default_salary_components(args):
|
||||
if not os.path.exists(SALARY_COMPONENTS_JSON):
|
||||
return
|
||||
|
||||
company = args.get("company_name") or frappe.db.get_single_value("Global Defaults", "default_company")
|
||||
|
||||
with open(SALARY_COMPONENTS_JSON, encoding="utf-8") as f:
|
||||
components = json.load(f)
|
||||
|
||||
|
|
@ -34,7 +36,7 @@ def create_default_salary_components(args):
|
|||
continue
|
||||
|
||||
data["doctype"] = "Salary Component"
|
||||
data["accounts"] = [{"company": company, "account": None}] if company else []
|
||||
data["accounts"] = []
|
||||
|
||||
frappe.get_doc(data).insert(ignore_permissions=True)
|
||||
|
||||
|
|
@ -60,6 +62,10 @@ def create_default_leave_types(args):
|
|||
data["doctype"] = "Leave Type"
|
||||
frappe.get_doc(data).insert(ignore_permissions=True)
|
||||
|
||||
for name in HRMS_DEFAULT_LEAVE_TYPES:
|
||||
if frappe.db.exists("Leave Type", name):
|
||||
frappe.delete_doc("Leave Type", name, ignore_permissions=True)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue