diff options
| author | Yannick Tivisse <yti@odoo.com> | 2016-07-13 11:19:34 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2016-07-13 12:53:34 +0200 |
| commit | 637208062116898f7faef27f850df4a88c941a0e (patch) | |
| tree | 3719c9fea279051352cbb4fbc5aaa2bf5f3e577a /addons/project_issue/models/project_issue.py | |
| parent | ee9b64a42837db28190403dd8a7f0231a3a4b71b (diff) | |
[FIX] project_issue: new api call to 'get_working_hours'
Diffstat (limited to 'addons/project_issue/models/project_issue.py')
| -rw-r--r-- | addons/project_issue/models/project_issue.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/addons/project_issue/models/project_issue.py b/addons/project_issue/models/project_issue.py index 8d4dacd0caf..7c0598ea54e 100644 --- a/addons/project_issue/models/project_issue.py +++ b/addons/project_issue/models/project_issue.py @@ -94,35 +94,21 @@ class ProjectIssue(models.Model): @api.depends('create_date', 'date_closed', 'date_open') def _compute_day(self): for issue in self: - # if the working hours on the project are not defined, use default ones (8 -> 12 and 13 -> 17 * 5), represented by None - calendar_id = None - if issue.project_id and issue.project_id.resource_calendar_id: - calendar_id = issue.project_id.resource_calendar_id.id + # if the working hours on the project are not defined, use default ones (8 -> 12 and 13 -> 17 * 5) + calendar = issue.project_id.resource_calendar_id dt_create_date = fields.Datetime.from_string(issue.create_date) if issue.date_open: dt_date_open = fields.Datetime.from_string(issue.date_open) issue.day_open = (dt_date_open - dt_create_date).total_seconds() / (24.0 * 3600) - # FIXME when resource.calendar is migrated to new api - # Old api call because get_working_hours uses get_weekdays - # which has a different behavior if the given id is None. - issue.working_hours_open = self.pool['resource.calendar'].get_working_hours( - self.env.cr, self.env.uid, calendar_id, dt_create_date, dt_date_open, - compute_leaves=True, resource_id=False, default_interval=(8, 16), - context=self.env.context - ) + issue.working_hours_open = calendar.get_working_hours(dt_create_date, dt_date_open, + compute_leaves=True, resource_id=False, default_interval=(8, 16)) if issue.date_closed: dt_date_closed = fields.Datetime.from_string(issue.date_closed) issue.day_close = (dt_date_closed - dt_create_date).total_seconds() / (24.0 * 3600) - # FIXME when resource.calendar is migrated to new api - # Old api call because get_working_hours uses get_weekdays - # which has a different behavior if the given id is None. - issue.working_hours_close = self.pool['resource.calendar'].get_working_hours( - self.env.cr, self.env.uid, calendar_id, dt_create_date, dt_date_closed, - compute_leaves=True, resource_id=False, default_interval=(8, 16), - context=self.env.context - ) + issue.working_hours_close = calendar.get_working_hours(dt_create_date, dt_date_closed, + compute_leaves=True, resource_id=False, default_interval=(8, 16)) @api.multi @api.depends('create_date', 'date_action_last', 'date_last_stage_update') |
