From 89093a26165ad61c63138c06ec6fe0575a33970a Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 10 Mar 2015 16:05:40 +0100 Subject: [PATCH] [FIX] hr_timesheet_sheet: performance improvment of timesheet report It always better to avoid doing the same join multiple times when possible. opw-629857 --- .../report/hr_timesheet_report.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py index 062a3010e05..e5acede5f88 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py @@ -46,24 +46,15 @@ class hr_timesheet_report(osv.osv): htss.date_from, htss.date_to, count(*) as nbr, - (SELECT sum(day.total_difference) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_diff, - (SELECT sum(day.total_timesheet) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_timesheet, - (SELECT sum(day.total_attendance) - FROM hr_timesheet_sheet_sheet AS sheet - LEFT JOIN hr_timesheet_sheet_sheet_day AS day - ON (sheet.id = day.sheet_id) where sheet.id=htss.id) as total_attendance, + sum(day.total_difference) as total_diff, + sum(day.total_timesheet) as total_timesheet, + sum(day.total_attendance) as total_attendance, aal.to_invoice, htss.department_id, htss.state""" def _from(self): - return super(hr_timesheet_report, self)._from() + "left join hr_timesheet_sheet_sheet as htss ON (hat.sheet_id=htss.id)" + return super(hr_timesheet_report, self)._from() + "left join hr_timesheet_sheet_sheet as htss ON (hat.sheet_id=htss.id) left join hr_timesheet_sheet_sheet_day AS day ON (htss.id = day.sheet_id)" def _group_by(self): return super(hr_timesheet_report, self)._group_by() + """,