From dcf598dc2d30adc45edf9750080a1e7acb873cbd Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 10 Aug 2020 18:03:12 +0530 Subject: [PATCH] Fix: requested Changes --- .../shift_assignment/shift_assignment.py | 8 ++-- .../doctype/shift_request/shift_request.json | 48 ++++++------------- .../hr/doctype/shift_request/shift_request.py | 2 + erpnext/hr/doctype/shift_type/shift_type.py | 7 ++- 4 files changed, 24 insertions(+), 41 deletions(-) diff --git a/erpnext/hr/doctype/shift_assignment/shift_assignment.py b/erpnext/hr/doctype/shift_assignment/shift_assignment.py index f5bd0d068e..20553b9a20 100644 --- a/erpnext/hr/doctype/shift_assignment/shift_assignment.py +++ b/erpnext/hr/doctype/shift_assignment/shift_assignment.py @@ -60,15 +60,17 @@ class ShiftAssignment(Document): 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(self.employee, self.shift_type, shift_details.name) + 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(self.employee, self.shift_type, shift_details.name) + 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: msg += _(" from {0}").format(getdate(self.start_date).strftime("%d-%m-%Y")) + title = "Ongoing Shift" if shift_details.end_date: msg += _(" to {0}").format(getdate(self.end_date).strftime("%d-%m-%Y")) + title = "Active Shift" if msg: - frappe.throw(msg) + frappe.throw(msg, title=title) @frappe.whitelist() def get_events(start, end, filters=None): diff --git a/erpnext/hr/doctype/shift_request/shift_request.json b/erpnext/hr/doctype/shift_request/shift_request.json index fee55dd14b..64cbdfff7d 100644 --- a/erpnext/hr/doctype/shift_request/shift_request.json +++ b/erpnext/hr/doctype/shift_request/shift_request.json @@ -26,9 +26,7 @@ "in_list_view": 1, "label": "Shift Type", "options": "Shift Type", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "employee", @@ -36,18 +34,14 @@ "in_list_view": 1, "label": "Employee", "options": "Employee", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fetch_from": "employee.employee_name", "fieldname": "employee_name", "fieldtype": "Data", "label": "Employee Name", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fetch_from": "employee.department", @@ -55,15 +49,11 @@ "fieldtype": "Link", "label": "Department", "options": "Department", - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "fieldname": "column_break_4", - "fieldtype": "Column Break", - "show_days": 1, - "show_seconds": 1 + "fieldtype": "Column Break" }, { "fieldname": "company", @@ -71,24 +61,18 @@ "in_list_view": 1, "label": "Company", "options": "Company", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "from_date", "fieldtype": "Date", "label": "From Date", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { "fieldname": "to_date", "fieldtype": "Date", - "label": "To Date", - "show_days": 1, - "show_seconds": 1 + "label": "To Date" }, { "fieldname": "amended_from", @@ -97,9 +81,7 @@ "no_copy": 1, "options": "Shift Request", "print_hide": 1, - "read_only": 1, - "show_days": 1, - "show_seconds": 1 + "read_only": 1 }, { "default": "Draft", @@ -107,23 +89,21 @@ "fieldtype": "Select", "label": "Status", "options": "Draft\nApproved\nRejected", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 }, { + "fetch_from": "employee.shift_request_approver", + "fetch_if_empty": 1, "fieldname": "approver", "fieldtype": "Link", "label": "Approver", "options": "User", - "reqd": 1, - "show_days": 1, - "show_seconds": 1 + "reqd": 1 } ], "is_submittable": 1, "links": [], - "modified": "2020-06-23 15:56:44.536207", + "modified": "2020-08-10 17:59:31.550558", "modified_by": "Administrator", "module": "HR", "name": "Shift Request", diff --git a/erpnext/hr/doctype/shift_request/shift_request.py b/erpnext/hr/doctype/shift_request/shift_request.py index 8a2e7eda6d..1c2801bf08 100644 --- a/erpnext/hr/doctype/shift_request/shift_request.py +++ b/erpnext/hr/doctype/shift_request/shift_request.py @@ -32,6 +32,8 @@ class ShiftRequest(Document): assignment_doc.insert() assignment_doc.submit() + frappe.msgprint(_("Shift Assignment: {0} created for Employee: {1}").format(frappe.bold(assignment_doc.name), frappe.bold(self.employee))) + def on_cancel(self): shift_assignment_list = frappe.get_list("Shift Assignment", {'employee': self.employee, 'shift_request': self.name}) if shift_assignment_list: diff --git a/erpnext/hr/doctype/shift_type/shift_type.py b/erpnext/hr/doctype/shift_type/shift_type.py index dfe094e6b7..dd08d31b01 100644 --- a/erpnext/hr/doctype/shift_type/shift_type.py +++ b/erpnext/hr/doctype/shift_type/shift_type.py @@ -78,10 +78,9 @@ 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, from_date=None, consider_default_shift=False): - filters = {'start_date':('>=', from_date), 'shift_type': self.name, 'docstatus': '1'} - if not from_date: - del filters['date'] + def get_assigned_employee(self, consider_default_shift=False): + filters = {'shift_type': self.name, 'docstatus': '1'} + assigned_employees = frappe.get_all('Shift Assignment', 'employee', filters, as_list=True) assigned_employees = [x[0] for x in assigned_employees]