diff --git a/addons/hr_timesheet/controllers/project.py b/addons/hr_timesheet/controllers/project.py index cf9afc7b4c3..970ae2fdb0f 100644 --- a/addons/hr_timesheet/controllers/project.py +++ b/addons/hr_timesheet/controllers/project.py @@ -10,6 +10,31 @@ from odoo.addons.project.controllers.portal import CustomerPortal class ProjectCustomerPortal(CustomerPortal): + def _prepare_project_sharing_session_info(self, project): + session_info = super()._prepare_project_sharing_session_info(project) + + company = project.company_id + timesheet_encode_uom = company.timesheet_encode_uom_id + project_time_mode_uom = company.project_time_mode_id + session_info['user_companies']['allowed_companies'][company.id].update( + timesheet_uom_id=timesheet_encode_uom.id, + timesheet_uom_factor=project_time_mode_uom._compute_quantity( + 1.0, + timesheet_encode_uom, + round=False + ), + ) + session_info['uom_ids'] = { + uom.id: + { + 'id': uom.id, + 'name': uom.name, + 'rounding': uom.rounding, + 'timesheet_widget': uom.timesheet_widget, + } for uom in [timesheet_encode_uom, project_time_mode_uom] + } + return session_info + 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() diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 3e756dd201c..c8a888bc27e 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -163,9 +163,10 @@ class AccountAnalyticLine(models.Model): def _apply_time_label(self, view_arch, related_model): doc = etree.XML(view_arch) Model = self.env[related_model] - encoding_uom = self.env.company.timesheet_encode_uom_id + # Just fetch the name of the uom in `timesheet_encode_uom_id` of the current company + encoding_uom_name = self.env.company.timesheet_encode_uom_id.with_context(prefetch_fields=False).sudo().name for node in doc.xpath("//field[@widget='timesheet_uom'][not(@string)] | //field[@widget='timesheet_uom_no_toggle'][not(@string)]"): - name_with_uom = re.sub(_('Hours') + "|Hours", encoding_uom.name or '', Model._fields[node.get('name')]._description_string(self.env), flags=re.IGNORECASE) + name_with_uom = re.sub(_('Hours') + "|Hours", encoding_uom_name or '', Model._fields[node.get('name')]._description_string(self.env), flags=re.IGNORECASE) node.set('string', name_with_uom) return etree.tostring(doc, encoding='unicode') diff --git a/addons/hr_timesheet/views/project_sharing_views.xml b/addons/hr_timesheet/views/project_sharing_views.xml index 95f82d8be2e..7a9798821a7 100644 --- a/addons/hr_timesheet/views/project_sharing_views.xml +++ b/addons/hr_timesheet/views/project_sharing_views.xml @@ -25,11 +25,11 @@