Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rearrange custom fields in employee master #42

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
153 changes: 153 additions & 0 deletions hrms/patches/v1_0/rearrange_employee_fields.py
Original file line number Diff line number Diff line change
@@ -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)
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
15 changes: 10 additions & 5 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 All @@ -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",
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