summaryrefslogtreecommitdiff
path: root/addons/project_issue/models/project_issue.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-01-23 14:01:27 +0100
committerThibault Delavallée <tde@odoo.com>2017-02-27 14:04:48 +0100
commitff32384b8ffd1abc3ab4ba12114feddc32ba1bf9 (patch)
tree788f840d4580f2d2a748e9e5b580cb8d0f96be85 /addons/project_issue/models/project_issue.py
parentac26fa3dd428786f7b1057980d0aee155c74a0f6 (diff)
[REF] resource: correctly take into account timezones and clean code
Currently timezones were not or incorrectly taken into account in resource computation. Indeed complexity comes from attendances being expressed in naive timezones valid for all users, whereas dates and leaves are computed into UTC. Computation should always be done in user timezone so that there are no overlapping days and all time intervals are correctly computed. A new timezone field is added on leaves to know in which timezone they were originally encoded. Indeed putting them in naive user timezone require its original timezone, not the current user timezone, as those can be different. This commit also contains code cleaning in resource to be a bit more pythonic, simplify method parameters and offer a more simple api to other modules. Eventually code field is removed on resource as it is not really necessary for resources. It is explicitly added on workcenter model who use it.
Diffstat (limited to 'addons/project_issue/models/project_issue.py')
-rw-r--r--addons/project_issue/models/project_issue.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/addons/project_issue/models/project_issue.py b/addons/project_issue/models/project_issue.py
index 024ab4e81b4..782ea8e9be4 100644
--- a/addons/project_issue/models/project_issue.py
+++ b/addons/project_issue/models/project_issue.py
@@ -91,8 +91,7 @@ class ProjectIssue(models.Model):
issue.day_open = (dt_date_open - dt_create_date).total_seconds() / (24.0 * 3600)
if issue.project_id.resource_calendar_id:
issue.working_hours_open = issue.project_id.resource_calendar_id.get_work_hours_count(
- dt_create_date, dt_date_open,
- compute_leaves=True, resource_id=False)
+ dt_create_date, dt_date_open, False, compute_leaves=True)
else:
issue.working_hours_open = 0
@@ -101,8 +100,7 @@ class ProjectIssue(models.Model):
issue.day_close = (dt_date_closed - dt_create_date).total_seconds() / (24.0 * 3600)
if issue.project_id.resource_calendar_id:
issue.working_hours_close = issue.project_id.resource_calendar_id.get_work_hours_count(
- dt_create_date, dt_date_closed,
- compute_leaves=True, resource_id=False)
+ dt_create_date, dt_date_closed, False, compute_leaves=True)
else:
issue.working_hours_close = 0