From aebcb17daf16a299b04cd457b11bf3d9ebbe2551 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 18 Sep 2017 16:58:24 +0530 Subject: [PATCH] Show thumbnail image in daily work summary (#10605) * Show thumbnail image in daily work summary * Crop thumbnail image into square * fix codacy --- .../daily_work_summary/daily_work_summary.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py b/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py index f03c6fa491..9ac74aae15 100644 --- a/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py +++ b/erpnext/hr/doctype/daily_work_summary/daily_work_summary.py @@ -51,6 +51,25 @@ class DailyWorkSummary(Document): d.sender_name = emp[0].employee_name if emp else d.sender d.image = emp[0].image if emp and emp[0].image else None + + original_image = d.image + # make thumbnail image + try: + if original_image: + file_name = frappe.get_list('File', {'file_url': original_image}) + + if file_name: + file_name = file_name[0].name + file_doc = frappe.get_doc('File', file_name) + thumbnail_image = file_doc.make_thumbnail( + set_as_thumbnail=False, + width=100, + height=100, + crop=True + ) + d.image = thumbnail_image + except: + d.image = original_image if d.sender in did_not_reply: did_not_reply.remove(d.sender)