Skip to content

Commit

Permalink
fix: rearrange custom fields in employee master
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Aug 23, 2022
1 parent 212c7b8 commit 40558d9
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 5 deletions.
5 changes: 5 additions & 0 deletions hrms/patches.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pre_model_sync]


[post_model_sync]
hrms.patches.v1_0.rearrange_employee_fields
151 changes: 151 additions & 0 deletions hrms/patches/v1_0/rearrange_employee_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
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": "branch",
},
{
"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, update=True)
7 changes: 6 additions & 1 deletion hrms/regional/india/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 9 additions & 4 deletions hrms/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -108,14 +108,19 @@ 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,
"fieldname": "payroll_cost_center",
"fieldtype": "Link",
"label": "Payroll Cost Center",
"options": "Cost Center",
"insert_after": "salary_mode",
"insert_after": "salary_cb",
},
],
"Company": [
Expand Down

0 comments on commit 40558d9

Please sign in to comment.