[FIX] hr_timesheet_sheet: Attendances & timesheets timezone
When creating timesheet, default from-date and to-date are adjusted for user timezone. Fixes #3627 User timezone considered when assigning attendance records to timesheet Fixes #3628 Closes #3632
This commit is contained in:
parent
a0d44f9952
commit
f243a01795
|
@ -192,7 +192,7 @@ class hr_timesheet_sheet(osv.osv):
|
|||
return (datetime.today() + relativedelta(weekday=0, days=-6)).strftime('%Y-%m-%d')
|
||||
elif r=='year':
|
||||
return time.strftime('%Y-01-01')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
return fields.date.context_today(self, cr, uid, context)
|
||||
|
||||
def _default_date_to(self, cr, uid, context=None):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
|
@ -203,7 +203,7 @@ class hr_timesheet_sheet(osv.osv):
|
|||
return (datetime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d')
|
||||
elif r=='year':
|
||||
return time.strftime('%Y-12-31')
|
||||
return time.strftime('%Y-%m-%d')
|
||||
return fields.date.context_today(self, cr, uid, context)
|
||||
|
||||
def _default_employee(self, cr, uid, context=None):
|
||||
emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)], context=context)
|
||||
|
@ -409,8 +409,12 @@ class hr_attendance(osv.osv):
|
|||
INNER JOIN resource_resource r
|
||||
ON (e.resource_id = r.id)
|
||||
ON (a.employee_id = e.id)
|
||||
WHERE %(date_to)s >= date_trunc('day', a.name)
|
||||
AND %(date_from)s <= a.name
|
||||
LEFT JOIN res_users u
|
||||
ON r.user_id = u.id
|
||||
LEFT JOIN res_partner p
|
||||
ON u.partner_id = p.id
|
||||
WHERE %(date_to)s >= date_trunc('day', a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))
|
||||
AND %(date_from)s <= date_trunc('day', a.name AT TIME ZONE 'UTC' AT TIME ZONE coalesce(p.tz, 'UTC'))
|
||||
AND %(user_id)s = r.user_id
|
||||
GROUP BY a.id""", {'date_from': ts.date_from,
|
||||
'date_to': ts.date_to,
|
||||
|
|
Loading…
Reference in New Issue