From 74f0a1ab7cfb62aa9531dd642dae786bb2f8e005 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 11 Aug 2020 19:00:43 +0530 Subject: [PATCH] fix: changes Requested --- .../doctype/department_approver/department_approver.py | 2 +- erpnext/hr/doctype/shift_assignment/shift_assignment.py | 9 +++------ erpnext/hr/doctype/shift_type/shift_type.py | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/erpnext/hr/doctype/department_approver/department_approver.py b/erpnext/hr/doctype/department_approver/department_approver.py index 6626ece963..9b2de0e1cb 100644 --- a/erpnext/hr/doctype/department_approver/department_approver.py +++ b/erpnext/hr/doctype/department_approver/department_approver.py @@ -48,7 +48,7 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters): field_name = "Expense Approver" elif filters.get("doctype") == "Shift Request": parentfield = "shift_request_approver" - field_name = "Approver" + field_name = "Shift Request Approver" if department_list: for d in department_list: approvers += frappe.db.sql("""select user.name, user.first_name, user.last_name from diff --git a/erpnext/hr/doctype/shift_assignment/shift_assignment.py b/erpnext/hr/doctype/shift_assignment/shift_assignment.py index 20553b9a20..4f5b59b7e2 100644 --- a/erpnext/hr/doctype/shift_assignment/shift_assignment.py +++ b/erpnext/hr/doctype/shift_assignment/shift_assignment.py @@ -41,7 +41,7 @@ class ShiftAssignment(Document): select name, shift_type, start_date ,end_date, docstatus, status from `tabShift Assignment` where - employee=%(employee)s and docstatus < 2 + employee=%(employee)s and docstatus = 1 and name != %(name)s and status = "Active" {0} @@ -53,14 +53,11 @@ class ShiftAssignment(Document): "name": self.name }, as_dict = 1) - for shift in assigned_shifts: - if shift.name: - self.throw_overlap_error(shift) + if len(assigned_shifts): + self.throw_overlap_error(assigned_shifts[0]) def throw_overlap_error(self, shift_details): shift_details = frappe._dict(shift_details) - if shift_details.docstatus == 0: - msg = _("Employee {0} has already applied for {1}: {2}").format(frappe.bold(self.employee), frappe.bold(self.shift_type), frappe.bold(shift_details.name)) if shift_details.docstatus == 1 and shift_details.status == "Active": msg = _("Employee {0} already has Active Shift {1}: {2}").format(frappe.bold(self.employee), frappe.bold(self.shift_type), frappe.bold(shift_details.name)) if shift_details.start_date: diff --git a/erpnext/hr/doctype/shift_type/shift_type.py b/erpnext/hr/doctype/shift_type/shift_type.py index dd08d31b01..054e7e3688 100644 --- a/erpnext/hr/doctype/shift_type/shift_type.py +++ b/erpnext/hr/doctype/shift_type/shift_type.py @@ -78,8 +78,10 @@ class ShiftType(Document): if shift_details and shift_details.shift_type.name == self.name: mark_attendance(employee, date, 'Absent', self.name) - def get_assigned_employee(self, consider_default_shift=False): - filters = {'shift_type': self.name, 'docstatus': '1'} + def get_assigned_employee(self, from_date=None, consider_default_shift=False): + filters = {'start_date':('>', from_date), 'shift_type': self.name, 'docstatus': '1'} + if not from_date: + del filters["start_date"] assigned_employees = frappe.get_all('Shift Assignment', 'employee', filters, as_list=True) assigned_employees = [x[0] for x in assigned_employees]