summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2015-09-07 11:01:26 +0200
committerGoffin Simon <sig@odoo.com>2015-09-08 10:08:45 +0200
commitbbd15cdca6e3bf6c92d3e230a2b7697c801a2cfb (patch)
treea6836a29a5a13ac6664c3713a025d688b8751d18 /addons
parent20f69bbce9c9fa6d84ec1937dd99bb3c66dfca90 (diff)
[FIX] resource: interval_get_multi
To compute the intervals of working time, the function interval_get_multi used 'hour_to' and 'hour_from' from "resource.calendar.attendance" model. 'hour_to' and 'hour_from' are not in UTC timezone. All the dates in odoo are compared in UTC. Then 'hour_to' and 'hour_from' must be converted. To take into account the minutes in this computation, the minutes from the start date are added in the variable todo (number of working hours). opw:648349
Diffstat (limited to 'addons')
-rw-r--r--addons/resource/resource.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/resource/resource.py b/addons/resource/resource.py
index 3021ea9fdb5..155d6ab4c68 100644
--- a/addons/resource/resource.py
+++ b/addons/resource/resource.py
@@ -25,7 +25,7 @@ from dateutil import rrule
import math
from faces import *
from openerp.osv import fields, osv
-from openerp.tools.float_utils import float_compare
+from openerp.tools.float_utils import float_compare, float_round as f_round
from openerp.tools.translate import _
from itertools import groupby
@@ -152,18 +152,21 @@ class resource_calendar(osv.osv):
for d, hours, id in date_and_hours_by_cal:
dt_from = datetime.strptime(d, '%Y-%m-%d %H:%M:%S')
+ tzinfo = fields.datetime.context_timestamp(cr, uid, dt_from, context={}).tzinfo
if not id:
td = int(hours)*3
results[(d, hours, id)] = [(dt_from, dt_from + timedelta(hours=td))]
continue
dt_leave = self._get_leaves(cr, uid, id, resource)
- todo = hours
+ todo = hours + f_round(float(dt_from.minute)/60, 2)
result = []
maxrecur = 100
current_hour = dt_from.hour
while float_compare(todo, 0, 4) and maxrecur:
for (hour_from,hour_to) in [(item['hour_from'], item['hour_to']) for item in hours_by_cal[id] if item['dayofweek'] == str(dt_from.weekday())]:
+ hour_from = dt_from.replace(hour=int(hour_from)).replace(tzinfo=tzinfo).astimezone(pytz.UTC).hour
+ hour_to = dt_from.replace(hour=int(hour_to)).replace(tzinfo=tzinfo).astimezone(pytz.UTC).hour
leave_flag = False
if (hour_to>current_hour) and float_compare(todo, 0, 4):
m = max(hour_from, current_hour)