diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py index 42d079db348..03e34143502 100644 --- a/erpnext/demo/setup/setup_data.py +++ b/erpnext/demo/setup/setup_data.py @@ -241,10 +241,10 @@ def setup_user_roles(): def setup_leave_allocation(): year = now_datetime().year for employee in frappe.get_all('Employee', fields=['name']): - leave_types = frappe.get_all("Leave Type", fields=['name', 'max_days_allowed']) + leave_types = frappe.get_all("Leave Type", fields=['name', 'max_continuous_days_allowed']) for leave_type in leave_types: - if not leave_type.max_days_allowed: - leave_type.max_days_allowed = 10 + if not leave_type.max_continuous_days_allowed: + leave_type.max_continuous_days_allowed = 10 leave_allocation = frappe.get_doc({ "doctype": "Leave Allocation", @@ -252,7 +252,7 @@ def setup_leave_allocation(): "from_date": "{0}-01-01".format(year), "to_date": "{0}-12-31".format(year), "leave_type": leave_type.name, - "new_leaves_allocated": random.randint(1, int(leave_type.max_days_allowed)) + "new_leaves_allocated": random.randint(1, int(leave_type.max_continuous_days_allowed)) }) leave_allocation.insert() leave_allocation.submit() diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 404501dfffe..8e2d64bf6ea 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -252,7 +252,7 @@ class LeaveApplication(Document): return leave_count_on_half_day_date * 0.5 def validate_max_days(self): - max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_days_allowed") + max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_continuous_days_allowed") if max_days and self.total_leave_days > cint(max_days): frappe.throw(_("Leave of type {0} cannot be longer than {1}").format(self.leave_type, max_days)) @@ -567,10 +567,10 @@ def add_holidays(events, start, end, employee, company): def get_mandatory_approval(doctype): mandatory = "" if doctype == "Leave Application": - mandatory = frappe.db.get_single_value('HR Settings', + mandatory = frappe.db.get_single_value('HR Settings', 'leave_approver_mandatory_in_leave_application') else: - mandatory = frappe.db.get_single_value('HR Settings', + mandatory = frappe.db.get_single_value('HR Settings', 'expense_approver_mandatory_in_expense_claim') return mandatory @@ -609,7 +609,7 @@ def get_approved_leaves_for_period(employee, leave_type, from_date, to_date): leave_app.from_date, leave_app.to_date) return leave_days - + def get_leave_approver(employee, department=None): if not department: department = frappe.db.get_value('Employee', employee, 'department') diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 9b0255983d6..b4f4c1ca931 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -367,7 +367,7 @@ class TestLeaveApplication(unittest.TestCase): leave_type_name = 'Test Leave Type', doctype = 'Leave Type', max_leaves_allowed = 15, - max_days_allowed = 3 + max_continuous_days_allowed = 3 )).insert() date = add_days(nowdate(), -7) diff --git a/erpnext/hr/doctype/leave_type/leave_type.json b/erpnext/hr/doctype/leave_type/leave_type.json index faddfe52e68..ef66a0a819d 100644 --- a/erpnext/hr/doctype/leave_type/leave_type.json +++ b/erpnext/hr/doctype/leave_type/leave_type.json @@ -113,7 +113,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "max_days_allowed", + "fieldname": "max_continuous_days_allowed", "fieldtype": "Int", "hidden": 0, "ignore_user_permissions": 0, diff --git a/erpnext/hr/doctype/leave_type/test_leave_type.js b/erpnext/hr/doctype/leave_type/test_leave_type.js index 4cde49bce30..d939a248102 100644 --- a/erpnext/hr/doctype/leave_type/test_leave_type.js +++ b/erpnext/hr/doctype/leave_type/test_leave_type.js @@ -10,7 +10,7 @@ QUnit.test("Test: Leave type [HR]", function (assert) { () => frappe.new_doc("Leave Type"), () => frappe.timeout(1), () => cur_frm.set_value("leave_type_name", "Test Leave type"), - () => cur_frm.set_value("max_days_allowed", "5"), + () => cur_frm.set_value("max_continuous_days_allowed", "5"), () => frappe.click_check('Is Carry Forward'), // save form () => cur_frm.save(), diff --git a/erpnext/patches/v11_0/rename_field_max_days_allowed.py b/erpnext/patches/v11_0/rename_field_max_days_allowed.py index d3ae99d0cd9..660e0adc75f 100644 --- a/erpnext/patches/v11_0/rename_field_max_days_allowed.py +++ b/erpnext/patches/v11_0/rename_field_max_days_allowed.py @@ -9,4 +9,3 @@ def execute(): frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""") frappe.reload_doc("hr", "doctype", "leave_type") rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed") - diff --git a/erpnext/setup/setup_wizard/operations/install_fixtures.py b/erpnext/setup/setup_wizard/operations/install_fixtures.py index 3309cbc39c1..afe982df4b8 100644 --- a/erpnext/setup/setup_wizard/operations/install_fixtures.py +++ b/erpnext/setup/setup_wizard/operations/install_fixtures.py @@ -84,7 +84,7 @@ def install(country=None): # leave type {'doctype': 'Leave Type', 'leave_type_name': _('Casual Leave'), 'name': _('Casual Leave'), - 'allow_encashment': 1, 'is_carry_forward': 1, 'max_days_allowed': '3', 'include_holiday': 1}, + 'allow_encashment': 1, 'is_carry_forward': 1, 'max_continuous_days_allowed': '3', 'include_holiday': 1}, {'doctype': 'Leave Type', 'leave_type_name': _('Compensatory Off'), 'name': _('Compensatory Off'), 'allow_encashment': 0, 'is_carry_forward': 0, 'include_holiday': 1}, {'doctype': 'Leave Type', 'leave_type_name': _('Sick Leave'), 'name': _('Sick Leave'),