Rename occurences of max_days_allowed to max_continuous allowed (#14180)

This commit is contained in:
Faris Ansari 2018-05-23 10:31:39 +05:30 committed by Nabin Hait
parent 83149644e3
commit 26eb513274
7 changed files with 12 additions and 13 deletions

View File

@ -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()

View File

@ -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')

View File

@ -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)

View File

@ -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,

View File

@ -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(),

View File

@ -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")

View File

@ -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'),