hr_timesheet_sheet: fix difference in view by day
bzr revid: ced-3efbc707ade4d84a9b9091e13d94f901fc6db0b4
This commit is contained in:
parent
ab11965365
commit
89b312484b
|
@ -377,44 +377,53 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
|
|||
def init(self, cr):
|
||||
cr.execute("""create or replace view hr_timesheet_sheet_sheet_day as
|
||||
SELECT
|
||||
MAX(id) as id,
|
||||
id,
|
||||
name,
|
||||
sheet_id,
|
||||
SUM(total_timesheet) as total_timesheet,
|
||||
CASE WHEN SUM(total_attendance) < 0
|
||||
THEN (SUM(total_attendance) +
|
||||
CASE WHEN current_date <> name
|
||||
THEN 1440
|
||||
ELSE (EXTRACT(hour FROM current_time) * 60) + EXTRACT(minute FROM current_time)
|
||||
END
|
||||
)
|
||||
ELSE SUM(total_attendance)
|
||||
END /60 as total_attendance,
|
||||
(SUM(total_attendance) - SUM(total_timesheet)) as total_difference
|
||||
total_timesheet,
|
||||
total_attendance,
|
||||
(total_attendance - total_timesheet) AS total_difference
|
||||
FROM
|
||||
((
|
||||
select
|
||||
min(hrt.id) as id,
|
||||
l.date::date as name,
|
||||
hrt.sheet_id as sheet_id,
|
||||
sum(l.unit_amount) as total_timesheet,
|
||||
0.0 as total_attendance
|
||||
from
|
||||
hr_analytic_timesheet hrt
|
||||
left join account_analytic_line l on (l.id = hrt.line_id)
|
||||
group by l.date::date, hrt.sheet_id
|
||||
) union (
|
||||
select
|
||||
-min(a.id) as id,
|
||||
a.name::date as name,
|
||||
a.sheet_id as sheet_id,
|
||||
0.0 as total_timesheet,
|
||||
SUM(((EXTRACT(hour FROM a.name) * 60) + EXTRACT(minute FROM a.name)) * (CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END)) as total_attendance
|
||||
from
|
||||
hr_attendance a
|
||||
group by a.name::date, a.sheet_id
|
||||
)) AS foo
|
||||
GROUP BY name, sheet_id""")
|
||||
SELECT
|
||||
MAX(id) as id,
|
||||
name,
|
||||
sheet_id,
|
||||
SUM(total_timesheet) as total_timesheet,
|
||||
CASE WHEN SUM(total_attendance) < 0
|
||||
THEN (SUM(total_attendance) +
|
||||
CASE WHEN current_date <> name
|
||||
THEN 1440
|
||||
ELSE (EXTRACT(hour FROM current_time) * 60) + EXTRACT(minute FROM current_time)
|
||||
END
|
||||
)
|
||||
ELSE SUM(total_attendance)
|
||||
END /60 as total_attendance
|
||||
FROM
|
||||
((
|
||||
select
|
||||
min(hrt.id) as id,
|
||||
l.date::date as name,
|
||||
hrt.sheet_id as sheet_id,
|
||||
sum(l.unit_amount) as total_timesheet,
|
||||
0.0 as total_attendance
|
||||
from
|
||||
hr_analytic_timesheet hrt
|
||||
left join account_analytic_line l on (l.id = hrt.line_id)
|
||||
group by l.date::date, hrt.sheet_id
|
||||
) union (
|
||||
select
|
||||
-min(a.id) as id,
|
||||
a.name::date as name,
|
||||
a.sheet_id as sheet_id,
|
||||
0.0 as total_timesheet,
|
||||
SUM(((EXTRACT(hour FROM a.name) * 60) + EXTRACT(minute FROM a.name)) * (CASE WHEN a.action = 'sign_in' THEN -1 ELSE 1 END)) as total_attendance
|
||||
from
|
||||
hr_attendance a
|
||||
group by a.name::date, a.sheet_id
|
||||
)) AS foo
|
||||
GROUP BY name, sheet_id
|
||||
)) AS bar""")
|
||||
hr_timesheet_sheet_sheet_day()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue