[FIX] resource,hr_payroll: disable timezone conversion
In the case of calculating payroll, we don't want to convert the datetimes using the timezone of the user as we really want to see what the employee has done from one date to another (usually from the start of the month to end of the month) Closes #26256 closes odoo/odoo#28977
This commit is contained in:
@@ -194,7 +194,7 @@ class HrPayslip(models.Model):
|
||||
current_leave_struct['number_of_days'] += leave_time / work_hours
|
||||
|
||||
# compute worked days
|
||||
work_data = contract.employee_id.get_work_days_data(day_from, day_to, calendar=contract.resource_calendar_id)
|
||||
work_data = contract.employee_id.with_context(no_tz_convert=True).get_work_days_data(day_from, day_to, calendar=contract.resource_calendar_id)
|
||||
attendances = {
|
||||
'name': _("Normal Working Days paid at 100%"),
|
||||
'sequence': 1,
|
||||
|
||||
@@ -417,8 +417,9 @@ class ResourceCalendar(models.Model):
|
||||
if not end_dt:
|
||||
end_dt = datetime.datetime.combine(start_dt.date(), datetime.time.max)
|
||||
|
||||
start_dt = to_naive_user_tz(start_dt, self.env.user)
|
||||
end_dt = to_naive_user_tz(end_dt, self.env.user)
|
||||
if not self.env.context.get('no_tz_convert', False):
|
||||
start_dt = to_naive_user_tz(start_dt, self.env.user)
|
||||
end_dt = to_naive_user_tz(end_dt, self.env.user)
|
||||
|
||||
for day in rrule.rrule(rrule.DAILY,
|
||||
dtstart=start_dt,
|
||||
|
||||
@@ -51,6 +51,7 @@ class ResourceMixin(models.AbstractModel):
|
||||
days_count = 0.0
|
||||
total_work_time = timedelta()
|
||||
calendar = calendar or self.resource_calendar_id
|
||||
calendar = calendar.with_context(no_tz_convert=self.env.context.get('no_tz_convert', False))
|
||||
for day_intervals in calendar._iter_work_intervals(
|
||||
from_datetime, to_datetime, self.resource_id.id,
|
||||
compute_leaves=True):
|
||||
|
||||
Reference in New Issue
Block a user