[IMP] hr_timesheet_attendance: improve generic UX for timesheet
Purpose of this commit to add the measures in timesheet/attendance report. task-2782768 closes odoo/odoo#85798 Related: odoo/enterprise#24982 Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<field name="total_attendance" type="measure" widget="timesheet_uom"/>
|
||||
<field name="total_timesheet" type="measure" widget="timesheet_uom"/>
|
||||
<field name="total_difference" type="measure" widget="timesheet_uom"/>
|
||||
<field name="timesheets_cost"/>
|
||||
<field name="attendance_cost"/>
|
||||
<field name="cost_difference"/>
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user