summaryrefslogtreecommitdiff
path: root/addons/resource/resource.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-08-06 11:36:54 +0200
committerThibault Delavallée <tde@openerp.com>2014-08-07 08:54:09 +0200
commit622b52d262f9f2aa8d0ecb4dab464416a6f65f06 (patch)
tree80baff14ad2386ecebe3fc836501ff41c50b63a3 /addons/resource/resource.py
parentf062eec6398e59f8636b00ef922be48a0f69c772 (diff)
[FIX] project_issue, resource: fixed computation of hours / days to open (assign) or close an issue. Those fields now have a conditional store, because they were not recomputed even when changing date_open and date_closed. Changing the stage now correctly changes the date_closed. Also added some fixes in resource module, the date was not correctly taken into account when computing the number of working hours between two dates.
Diffstat (limited to 'addons/resource/resource.py')
-rw-r--r--addons/resource/resource.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/addons/resource/resource.py b/addons/resource/resource.py
index 5a43234ac46..b16fd210593 100644
--- a/addons/resource/resource.py
+++ b/addons/resource/resource.py
@@ -329,7 +329,8 @@ class resource_calendar(osv.osv):
# no calendar: try to use the default_interval, then return directly
if id is None:
if default_interval:
- intervals.append((start_dt.replace(hour=default_interval[0]), start_dt.replace(hour=default_interval[1])))
+ working_interval = (start_dt.replace(hour=default_interval[0], minute=0, second=0), start_dt.replace(hour=default_interval[1], minute=0, second=0))
+ intervals = self.interval_remove_leaves(working_interval, work_limits)
return intervals
working_intervals = []
@@ -371,10 +372,16 @@ class resource_calendar(osv.osv):
resource_id=None, default_interval=None, context=None):
hours = 0.0
for day in rrule.rrule(rrule.DAILY, dtstart=start_dt,
- until=end_dt + datetime.timedelta(days=1),
+ until=(end_dt + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0),
byweekday=self.get_weekdays(cr, uid, id, context=context)):
+ day_start_dt = day.replace(hour=0, minute=0, second=0)
+ if start_dt and day.date() == start_dt.date():
+ day_start_dt = start_dt
+ day_end_dt = day.replace(hour=23, minute=59, second=59)
+ if end_dt and day.date() == end_dt.date():
+ day_end_dt = end_dt
hours += self.get_working_hours_of_date(
- cr, uid, id, start_dt=day,
+ cr, uid, id, start_dt=day_start_dt, end_dt=day_end_dt,
compute_leaves=compute_leaves, resource_id=resource_id,
default_interval=default_interval,
context=context)