From de24c2abcc09250d4ae9cbcffa7be10776565c04 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 7 Sep 2022 12:13:34 +0530 Subject: [PATCH] fix: rearrange custom fields in employee master --- hrms/patches.txt | 5 + .../patches/v1_0/rearrange_employee_fields.py | 153 ++++++++++++++++++ hrms/regional/india/setup.py | 7 +- hrms/setup.py | 15 +- 4 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 hrms/patches/v1_0/rearrange_employee_fields.py diff --git a/hrms/patches.txt b/hrms/patches.txt index e69de29bb2..8fbb211532 100644 --- a/hrms/patches.txt +++ b/hrms/patches.txt @@ -0,0 +1,5 @@ +[pre_model_sync] + + +[post_model_sync] +hrms.patches.v1_0.rearrange_employee_fields \ No newline at end of file diff --git a/hrms/patches/v1_0/rearrange_employee_fields.py b/hrms/patches/v1_0/rearrange_employee_fields.py new file mode 100644 index 0000000000..881446341c --- /dev/null +++ b/hrms/patches/v1_0/rearrange_employee_fields.py @@ -0,0 +1,153 @@ +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_fields + + +def execute(): + custom_fields = { + "Employee": [ + { + "fieldname": "employment_type", + "fieldtype": "Link", + "ignore_user_permissions": 1, + "label": "Employment Type", + "oldfieldname": "employment_type", + "oldfieldtype": "Link", + "options": "Employment Type", + "insert_after": "department", + }, + { + "fieldname": "job_applicant", + "fieldtype": "Link", + "label": "Job Applicant", + "options": "Job Applicant", + "insert_after": "employment_details", + }, + { + "fieldname": "grade", + "fieldtype": "Link", + "label": "Grade", + "options": "Employee Grade", + "insert_after": "branch", + }, + { + "fieldname": "default_shift", + "fieldtype": "Link", + "label": "Default Shift", + "options": "Shift Type", + "insert_after": "holiday_list", + }, + { + "collapsible": 1, + "fieldname": "health_insurance_section", + "fieldtype": "Section Break", + "label": "Health Insurance", + "insert_after": "health_details", + }, + { + "fieldname": "health_insurance_provider", + "fieldtype": "Link", + "label": "Health Insurance Provider", + "options": "Employee Health Insurance", + "insert_after": "health_insurance_section", + }, + { + "depends_on": "eval:doc.health_insurance_provider", + "fieldname": "health_insurance_no", + "fieldtype": "Data", + "label": "Health Insurance No", + "insert_after": "health_insurance_provider", + }, + { + "fieldname": "approvers_section", + "fieldtype": "Section Break", + "label": "Approvers", + "insert_after": "default_shift", + }, + { + "fieldname": "expense_approver", + "fieldtype": "Link", + "label": "Expense Approver", + "options": "User", + "insert_after": "approvers_section", + }, + { + "fieldname": "leave_approver", + "fieldtype": "Link", + "label": "Leave Approver", + "options": "User", + "insert_after": "expense_approver", + }, + { + "fieldname": "column_break_45", + "fieldtype": "Column Break", + "insert_after": "leave_approver", + }, + { + "fieldname": "shift_request_approver", + "fieldtype": "Link", + "label": "Shift Request Approver", + "options": "User", + "insert_after": "column_break_45", + }, + { + "fieldname": "salary_cb", + "fieldtype": "Column Break", + "insert_after": "salary_mode", + }, + { + "fetch_from": "department.payroll_cost_center", + "fetch_if_empty": 1, + "fieldname": "payroll_cost_center", + "fieldtype": "Link", + "label": "Payroll Cost Center", + "options": "Cost Center", + "insert_after": "salary_cb", + }, + ], + } + + if frappe.db.exists("Company", {"country": "India"}): + custom_fields["Employee"].extend( + [ + { + "fieldname": "bank_cb", + "fieldtype": "Column Break", + "insert_after": "bank_ac_no", + }, + { + "fieldname": "ifsc_code", + "label": "IFSC Code", + "fieldtype": "Data", + "insert_after": "bank_cb", + "print_hide": 1, + "depends_on": 'eval:doc.salary_mode == "Bank"', + "translatable": 0, + }, + { + "fieldname": "pan_number", + "label": "PAN Number", + "fieldtype": "Data", + "insert_after": "payroll_cost_center", + "print_hide": 1, + "translatable": 0, + }, + { + "fieldname": "micr_code", + "label": "MICR Code", + "fieldtype": "Data", + "insert_after": "ifsc_code", + "print_hide": 1, + "depends_on": 'eval:doc.salary_mode == "Bank"', + "translatable": 0, + }, + { + "fieldname": "provident_fund_account", + "label": "Provident Fund Account", + "fieldtype": "Data", + "insert_after": "pan_number", + "translatable": 0, + }, + ] + ) + + create_custom_fields(custom_fields) diff --git a/hrms/regional/india/setup.py b/hrms/regional/india/setup.py index e9de545d12..8f53e00a99 100644 --- a/hrms/regional/india/setup.py +++ b/hrms/regional/india/setup.py @@ -33,11 +33,16 @@ def get_custom_fields(): }, ], "Employee": [ + { + "fieldname": "bank_cb", + "fieldtype": "Column Break", + "insert_after": "bank_ac_no", + }, { "fieldname": "ifsc_code", "label": "IFSC Code", "fieldtype": "Data", - "insert_after": "bank_ac_no", + "insert_after": "bank_cb", "print_hide": 1, "depends_on": 'eval:doc.salary_mode == "Bank"', "translatable": 0, diff --git a/hrms/setup.py b/hrms/setup.py index f4e73a75f4..60694dd541 100644 --- a/hrms/setup.py +++ b/hrms/setup.py @@ -32,7 +32,7 @@ def get_custom_fields(): "oldfieldname": "employment_type", "oldfieldtype": "Link", "options": "Employment Type", - "insert_after": "employee_name", + "insert_after": "department", }, { "fieldname": "job_applicant", @@ -46,7 +46,7 @@ def get_custom_fields(): "fieldtype": "Link", "label": "Grade", "options": "Employee Grade", - "insert_after": "column_break_31", + "insert_after": "branch", }, { "fieldname": "default_shift", @@ -60,7 +60,7 @@ def get_custom_fields(): "fieldname": "health_insurance_section", "fieldtype": "Section Break", "label": "Health Insurance", - "insert_after": "bank_ac_no", + "insert_after": "health_details", }, { "fieldname": "health_insurance_provider", @@ -80,7 +80,7 @@ def get_custom_fields(): "fieldname": "approvers_section", "fieldtype": "Section Break", "label": "Approvers", - "insert_after": "branch", + "insert_after": "default_shift", }, { "fieldname": "expense_approver", @@ -108,6 +108,11 @@ def get_custom_fields(): "options": "User", "insert_after": "column_break_45", }, + { + "fieldname": "salary_cb", + "fieldtype": "Column Break", + "insert_after": "salary_mode", + }, { "fetch_from": "department.payroll_cost_center", "fetch_if_empty": 1, @@ -115,7 +120,7 @@ def get_custom_fields(): "fieldtype": "Link", "label": "Payroll Cost Center", "options": "Cost Center", - "insert_after": "salary_mode", + "insert_after": "salary_cb", }, ], "Company": [