From 37cd1b8021fc82f982871df8c150f625b936c524 Mon Sep 17 00:00:00 2001 From: michellealva Date: Mon, 20 Jul 2020 13:04:46 +0530 Subject: [PATCH 1/2] fix: Heatmap in Vehicle --- erpnext/hr/doctype/vehicle/vehicle.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/vehicle/vehicle.py b/erpnext/hr/doctype/vehicle/vehicle.py index a75cfa6125..57e2594d1b 100644 --- a/erpnext/hr/doctype/vehicle/vehicle.py +++ b/erpnext/hr/doctype/vehicle/vehicle.py @@ -13,4 +13,11 @@ class Vehicle(Document): if getdate(self.start_date) > getdate(self.end_date): frappe.throw(_("Insurance Start date should be less than Insurance End date")) if getdate(self.carbon_check_date) > getdate(): - frappe.throw(_("Last carbon check date cannot be a future date")) \ No newline at end of file + frappe.throw(_("Last carbon check date cannot be a future date")) + +def get_timeline_data(doctype, name): + '''Return timeline for vehicle log''' + return dict(frappe.db.sql('''select unix_timestamp(date), count(*) + from `tabVehicle Log` where license_plate=%s + and date > date_sub(curdate(), interval 1 year) + group by date''', name)) From 8c7d8ba917ffc623e75e099330cdd09d035a7eec Mon Sep 17 00:00:00 2001 From: michellealva Date: Mon, 20 Jul 2020 13:12:17 +0530 Subject: [PATCH 2/2] fix: remove tab in code --- erpnext/hr/doctype/vehicle/vehicle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/vehicle/vehicle.py b/erpnext/hr/doctype/vehicle/vehicle.py index 57e2594d1b..1df5068268 100644 --- a/erpnext/hr/doctype/vehicle/vehicle.py +++ b/erpnext/hr/doctype/vehicle/vehicle.py @@ -15,7 +15,7 @@ class Vehicle(Document): if getdate(self.carbon_check_date) > getdate(): frappe.throw(_("Last carbon check date cannot be a future date")) -def get_timeline_data(doctype, name): +def get_timeline_data(doctype, name): '''Return timeline for vehicle log''' return dict(frappe.db.sql('''select unix_timestamp(date), count(*) from `tabVehicle Log` where license_plate=%s