From 0da201c6a5d6467d3e7a392ae1bb4c616681d364 Mon Sep 17 00:00:00 2001 From: Afshan Date: Mon, 4 Jan 2021 19:04:05 +0530 Subject: [PATCH] fix: set company in leave allocation and leave ledger entry --- .../doctype/leave_allocation/leave_allocation.json | 12 +++++++++++- .../leave_ledger_entry/leave_ledger_entry.json | 14 +++++++++++++- erpnext/patches.txt | 1 + .../v13_0/set_company_in_leave_ledger_entry.py | 7 +++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 erpnext/patches/v13_0/set_company_in_leave_ledger_entry.py diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.json b/erpnext/hr/doctype/leave_allocation/leave_allocation.json index 4b315014da..3a300c0d63 100644 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.json +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.json @@ -11,6 +11,7 @@ "employee", "employee_name", "department", + "company", "column_break1", "leave_type", "from_date", @@ -219,6 +220,15 @@ "label": "Leave Policy Assignment", "options": "Leave Policy Assignment", "read_only": 1 + }, + { + "fetch_from": "employee.company", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "read_only": 1, + "reqd": 1 } ], "icon": "fa fa-ok", @@ -226,7 +236,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-08-20 14:25:10.314323", + "modified": "2021-01-04 18:46:13.184104", "modified_by": "Administrator", "module": "HR", "name": "Leave Allocation", diff --git a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.json b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.json index 4abba5f2d4..d74760a5cf 100644 --- a/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.json +++ b/erpnext/hr/doctype/leave_ledger_entry/leave_ledger_entry.json @@ -1,4 +1,5 @@ { + "actions": [], "creation": "2019-05-09 15:47:39.760406", "doctype": "DocType", "engine": "InnoDB", @@ -8,6 +9,7 @@ "leave_type", "transaction_type", "transaction_name", + "company", "leaves", "column_break_7", "from_date", @@ -106,12 +108,22 @@ "fieldtype": "Link", "label": "Holiday List", "options": "Holiday List" + }, + { + "fetch_from": "employee.company", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "read_only": 1, + "reqd": 1 } ], "in_create": 1, "index_web_pages_for_search": 1, "is_submittable": 1, - "modified": "2020-09-04 12:16:36.569066", + "links": [], + "modified": "2021-01-04 18:47:45.146652", "modified_by": "Administrator", "module": "HR", "name": "Leave Ledger Entry", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f2e4f72d67..923ed2f339 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -742,3 +742,4 @@ erpnext.patches.v13_0.updates_for_multi_currency_payroll erpnext.patches.v13_0.create_leave_policy_assignment_based_on_employee_current_leave_policy erpnext.patches.v13_0.add_po_to_global_search erpnext.patches.v13_0.update_returned_qty_in_pr_dn +erpnext.patches.v13_0.set_company_in_leave_ledger_entry \ No newline at end of file diff --git a/erpnext/patches/v13_0/set_company_in_leave_ledger_entry.py b/erpnext/patches/v13_0/set_company_in_leave_ledger_entry.py new file mode 100644 index 0000000000..66857c4e65 --- /dev/null +++ b/erpnext/patches/v13_0/set_company_in_leave_ledger_entry.py @@ -0,0 +1,7 @@ +import frappe + +def execute(): + frappe.reload_doc('HR', 'doctype', 'Leave Allocation') + frappe.reload_doc('HR', 'doctype', 'Leave Ledger Entry') + frappe.db.sql("""update `tabLeave Ledger Entry` as lle set company = (select company from `tabEmployee` where employee = lle.employee)""") + frappe.db.sql("""update `tabLeave Allocation` as la set company = (select company from `tabEmployee` where employee = la.employee)""") \ No newline at end of file