Fix: requested Changes

This commit is contained in:
Anurag Mishra 2020-08-10 18:03:12 +05:30
parent d5c921e358
commit dcf598dc2d
4 changed files with 24 additions and 41 deletions

View File

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

View File

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

View File

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

View File

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