diff --git a/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report.py b/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report.py
index 18f1ef1bd2f..4cd571b72b1 100644
--- a/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report.py
+++ b/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report.py
@@ -9,11 +9,14 @@ class TimesheetAttendance(models.Model):
_auto = False
_description = 'Timesheet Attendance Report'
- user_id = fields.Many2one('res.users')
- date = fields.Date()
- total_timesheet = fields.Float()
- total_attendance = fields.Float()
- total_difference = fields.Float()
+ user_id = fields.Many2one('res.users', readonly=True)
+ date = fields.Date(readonly=True)
+ total_timesheet = fields.Float("Timesheets Hours", readonly=True)
+ total_attendance = fields.Float("Attendance Hours", readonly=True)
+ total_difference = fields.Float("Hours Difference", readonly=True)
+ timesheets_cost = fields.Float("Timesheet Cost", readonly=True)
+ attendance_cost = fields.Float("Attendance Cost", readonly=True)
+ cost_difference = fields.Float("Cost Difference", readonly=True)
company_id = fields.Many2one('res.company', string='Company', readonly=True)
def init(self):
@@ -26,10 +29,14 @@ class TimesheetAttendance(models.Model):
t.company_id,
coalesce(sum(t.attendance), 0) AS total_attendance,
coalesce(sum(t.timesheet), 0) AS total_timesheet,
- coalesce(sum(t.attendance), 0) - coalesce(sum(t.timesheet), 0) as total_difference
+ coalesce(sum(t.attendance), 0) - coalesce(sum(t.timesheet), 0) as total_difference,
+ NULLIF(sum(t.timesheet) * t.emp_cost, 0) as timesheets_cost,
+ NULLIF(sum(t.attendance) * t.emp_cost, 0) as attendance_cost,
+ NULLIF((coalesce(sum(t.attendance), 0) - coalesce(sum(t.timesheet), 0)) * t.emp_cost, 0) as cost_difference
FROM (
SELECT
-hr_attendance.id AS id,
+ hr_employee.timesheet_cost AS emp_cost,
resource_resource.user_id AS user_id,
hr_attendance.worked_hours AS attendance,
NULL AS timesheet,
@@ -41,15 +48,17 @@ class TimesheetAttendance(models.Model):
UNION ALL
SELECT
ts.id AS id,
+ hr_employee.timesheet_cost AS emp_cost,
ts.user_id AS user_id,
NULL AS attendance,
ts.unit_amount AS timesheet,
ts.date AS date,
NULL AS company_id
FROM account_analytic_line AS ts
+ LEFT JOIN hr_employee ON hr_employee.id = ts.employee_id
WHERE ts.project_id IS NOT NULL
) AS t
- GROUP BY t.user_id, t.date, t.company_id
+ GROUP BY t.user_id, t.date, t.company_id, t.emp_cost
ORDER BY t.date
)
""" % self._table)
diff --git a/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report_view.xml b/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report_view.xml
index a66c4f12576..600f32eaf83 100644
--- a/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report_view.xml
+++ b/addons/hr_timesheet_attendance/report/hr_timesheet_attendance_report_view.xml
@@ -22,6 +22,9 @@
+
+
+