Skip to content

Commit

Permalink
fix: add doctype list to ignore to hooks directly
Browse files Browse the repository at this point in the history
(cherry picked from commit 5051d6a)
  • Loading branch information
AyshaHakeem authored and mergify[bot] committed Jan 24, 2025
1 parent 2c2229e commit defbcf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
16 changes: 13 additions & 3 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from hrms.overrides.company import get_company_data_to_be_ignored

app_name = "hrms"
app_title = "Frappe HR"
app_publisher = "Frappe Technologies Pvt. Ltd."
Expand Down Expand Up @@ -351,4 +349,16 @@
# For example: Role, Gender, etc.
# translated_search_doctypes = []

company_data_to_be_ignored = get_company_data_to_be_ignored()
company_data_to_be_ignored = [
"Salary Component Account",
"Salary Structure",
"Salary Structure Assignment",
"Payroll Period",
"Income Tax Slab",
"Leave Policy",
"Leave Period",
"Leave Policy Assignment",
"Employee Onboarding Template",
"Employee Separation Template",
"Job Offer Term Template",
]
21 changes: 2 additions & 19 deletions hrms/overrides/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,6 @@ def validate_default_accounts(doc, method=None):
)


def get_company_data_to_be_ignored():
if "erpnext" in frappe.get_installed_apps():
return [
"Salary Component Account",
"Salary Structure",
"Salary Structure Assignment",
"Payroll Period",
"Income Tax Slab",
"Leave Policy",
"Leave Period",
"Leave Policy Assignment",
"Employee Onboarding Template",
"Employee Separation Template",
"Job Offer Term Template",
]
return []


def unset_company_field(doc, method=None):
unset_company_field_for_single_doctype(doc)
unset_company_field_for_non_single_doctype(doc)
Expand All @@ -172,7 +154,8 @@ def unset_company_field_for_single_doctype(doc):


def unset_company_field_for_non_single_doctype(doc):
for doctype in get_company_data_to_be_ignored():
company_data_to_be_ignored = frappe.get_hooks("company_data_to_be_ignored") or []
for doctype in company_data_to_be_ignored:
company_field = frappe.get_all(
"DocField",
filters={"parent": doctype, "fieldtype": "Link", "options": "Company"},
Expand Down

0 comments on commit defbcf6

Please sign in to comment.