diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_timesheet/controllers/project.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_timesheet/controllers/project.py')
| -rw-r--r-- | addons/hr_timesheet/controllers/project.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/hr_timesheet/controllers/project.py b/addons/hr_timesheet/controllers/project.py new file mode 100644 index 00000000..31fbe2f3 --- /dev/null +++ b/addons/hr_timesheet/controllers/project.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from collections import defaultdict +from odoo.http import request +from odoo.osv import expression + +from odoo.addons.project.controllers.portal import CustomerPortal + + +class ProjectCustomerPortal(CustomerPortal): + + def _task_get_page_view_values(self, task, access_token, **kwargs): + values = super(ProjectCustomerPortal, self)._task_get_page_view_values(task, access_token, **kwargs) + domain = request.env['account.analytic.line']._timesheet_get_portal_domain() + task_domain = expression.AND([domain, [('task_id', '=', task.id)]]) + subtask_domain = expression.AND([domain, [('task_id', 'in', task.child_ids.ids)]]) + timesheets = request.env['account.analytic.line'].sudo().search(task_domain) + subtasks_timesheets = request.env['account.analytic.line'].sudo().search(subtask_domain) + timesheets_by_subtask = defaultdict(lambda: request.env['account.analytic.line'].sudo()) + for timesheet in subtasks_timesheets: + timesheets_by_subtask[timesheet.task_id] |= timesheet + values['timesheets'] = timesheets + values['timesheets_by_subtask'] = timesheets_by_subtask + values['is_uom_day'] = request.env['account.analytic.line']._is_timesheet_encode_uom_day() + return values |
