From d04b1c2abce78ebf06f697ea5faa3acb353d25e7 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 13 Sep 2021 15:02:09 +0200 Subject: [PATCH 01/22] [FIX] project: remove import button in favorite menu for project sharing Before this commit, the portal user can see this button, but this button should not be accessible by collaborators. This commit removes the import button in project sharing feature to not allow this to collaborators. task-2633229 closes #77156 X-original-commit: 74d7308dfb8df0b923e68aa228ec406e36b0b89a --- addons/project/views/project_sharing_views.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/project/views/project_sharing_views.xml b/addons/project/views/project_sharing_views.xml index 01264b38385..528742ea850 100644 --- a/addons/project/views/project_sharing_views.xml +++ b/addons/project/views/project_sharing_views.xml @@ -27,6 +27,7 @@ on_create="quick_create" quick_create_view="project.project_sharing_quick_create_task_form" archivable="0" + import="0" > @@ -115,7 +116,7 @@ project.task 999 - + From 0b8961a9630692b6e2938a0958251bd5693d5df2 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 13 Sep 2021 15:15:27 +0200 Subject: [PATCH 02/22] [FIX] project: search view in project sharing feature Before this commit, we add the same search view than one in backend views. But some filters are not needed since we display only one project. For instance, the group by project is not useful since we have only one project. This commit removes the groups by project and create_date and add a separator in filters. task-2633229 closes #77156 X-original-commit: 1af17e529161bb745a183458b91972fa3a9b69f7 --- addons/project/views/project_sharing_views.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/project/views/project_sharing_views.xml b/addons/project/views/project_sharing_views.xml index 528742ea850..be37ff64aa4 100644 --- a/addons/project/views/project_sharing_views.xml +++ b/addons/project/views/project_sharing_views.xml @@ -233,6 +233,7 @@ + - + + - + + From 150686947bc0229a239d1a1b4a31f323c553952c Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 13 Sep 2021 15:18:40 +0200 Subject: [PATCH 03/22] [FIX] project,hr_timesheet: add uom in session to use widget Before this commit, since we don't have the uom in the session, the timesheet_uom widgets does not work in project sharing feature. Because those widgets need the uom stored in the session. This commit adds the uoms needed in the session used for project sharing feature. task-2633229 closes #77156 X-original-commit: a8f27ac776e8f381cb467be3a0256b197d6e688f --- addons/hr_timesheet/controllers/project.py | 25 ++++++++++++++++++++++ addons/project/controllers/portal.py | 18 ++++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) 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/project/controllers/portal.py b/addons/project/controllers/portal.py index e0f1cc09b6c..7ff3097d604 100644 --- a/addons/project/controllers/portal.py +++ b/addons/project/controllers/portal.py @@ -159,12 +159,7 @@ class ProjectCustomerPortal(CustomerPortal): values['task_url'] = 'project/%s/task' % project_id return request.render("project.portal_my_project", values) - @http.route("/my/project//project_sharing", type="http", auth="user", methods=['GET']) - def render_project_backend_view(self, project_id): - project = request.env['project.project'].sudo().browse(project_id) - if not project.exists() or not project.with_user(request.env.user)._check_project_sharing_access(): - return request.not_found() - + def _prepare_project_sharing_session_info(self, project): session_info = request.env['ir.http'].session_info() user_context = request.session.get_context() if request.session.uid else {} mods = conf.server_wide_modules or [] @@ -190,11 +185,20 @@ class ProjectCustomerPortal(CustomerPortal): }, }, }, + # FIXME: See if we prefer to give only the currency that the portal user just need to see the correct information in project sharing + currencies=request.env['ir.http'].get_currencies(), ) + return session_info + + @http.route("/my/project//project_sharing", type="http", auth="user", methods=['GET']) + def render_project_backend_view(self, project_id): + project = request.env['project.project'].sudo().browse(project_id) + if not project.exists() or not project.with_user(request.env.user)._check_project_sharing_access(): + return request.not_found() return request.render( 'project.project_sharing_embed', - {'session_info': session_info}, + {'session_info': self._prepare_project_sharing_session_info(project)}, ) @http.route('/my/project//task/', type='http', auth='public', website=True) From 7beaa042011ceb3f116a1be477f315415687c04c Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Fri, 17 Sep 2021 10:29:30 +0200 Subject: [PATCH 04/22] [FIX] sale_project: remove the SO stat button in project sharing Before this commit, the user can see the stat button but this button is disabled. Since this button gives no more information. This commit removes this stat button in the project sharing feature. task-2633229 closes #77156 X-original-commit: 0e6995533f6733993a4d2554b2ed407f3a3ba3e1 --- addons/sale_project/views/project_sharing_views.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale_project/views/project_sharing_views.xml b/addons/sale_project/views/project_sharing_views.xml index d4776bfcdc6..85d4b1d8ca6 100644 --- a/addons/sale_project/views/project_sharing_views.xml +++ b/addons/sale_project/views/project_sharing_views.xml @@ -8,9 +8,9 @@
-
From 596a6769846e9ddb176c47d15d7cb59491bfbef9 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 13 Sep 2021 14:56:09 +0200 Subject: [PATCH 05/22] [FIX] hr_timesheet: remove avatar widget on employee_id of timesheets Before this commit, when we use the same widget than backend view, the problem is the portal user cannot see the avatar picture of the employees whom are not in the same company than him. For this reason, this commit removes the avatar widget for this field. task-2633229 closes #77156 X-original-commit: 3a21160d879d6244527b6b5640f796cfb84edfe2 --- addons/hr_timesheet/views/project_sharing_views.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/hr_timesheet/views/project_sharing_views.xml b/addons/hr_timesheet/views/project_sharing_views.xml index 95f82d8be2e..a6c71f128cb 100644 --- a/addons/hr_timesheet/views/project_sharing_views.xml +++ b/addons/hr_timesheet/views/project_sharing_views.xml @@ -37,18 +37,19 @@ - + - + + - + From 4c12d0410d8f798fed66b7639f77bd43b937b2de Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 13 Sep 2021 08:17:44 +0200 Subject: [PATCH 06/22] [FIX] project: remove checkboxes in list view for project sharing Before this commit, the portal user can select multiple tasks in the list view with the checkboxes but no action is available. For this reason, this commit removes these checkboxes. task-2633229 closes #77156 X-original-commit: cef79697a014c6443c1d1dfdcf498c18fcb27fb9 --- addons/project/static/src/project_sharing/views/list/view.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/project/static/src/project_sharing/views/list/view.js b/addons/project/static/src/project_sharing/views/list/view.js index 4c202d29682..1f70f9c5f01 100644 --- a/addons/project/static/src/project_sharing/views/list/view.js +++ b/addons/project/static/src/project_sharing/views/list/view.js @@ -7,4 +7,8 @@ export default ListView.extend({ config: Object.assign({}, ListView.prototype.config, { Controller, }), + + init: function (viewInfo, params) { + return this._super(viewInfo, {...params, hasSelectors: false}); + } }); From 8f841553378f554957289f31346219f50d5c5660 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 16 Sep 2021 16:55:56 +0200 Subject: [PATCH 07/22] [FIX] project: not set by default the height of the chatter Before this commit, the border left displayed when the chatter is aside the task form view is not from the top to the bottom of the page in project sharing feature. This commit removes the fit-content set to the height in css to have the border left displayed from the top to the bottom as expected in project sharing feature. task-2633229 closes #77156 X-original-commit: 886bc7577b2d6f437c28ea18e5786b36930a7cc2 --- addons/project/static/src/scss/project_sharing/chatter.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/project/static/src/scss/project_sharing/chatter.scss b/addons/project/static/src/scss/project_sharing/chatter.scss index ab108ff1d22..5f63bb31f59 100644 --- a/addons/project/static/src/scss/project_sharing/chatter.scss +++ b/addons/project/static/src/scss/project_sharing/chatter.scss @@ -2,7 +2,6 @@ display: flex; background-color: $white; border-color: $border-color; - height: fit-content; .o_portal_chatter { width: 100%; From 0f24225bbea17b23acbddb10c555a9a12fc5f44d Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Mon, 20 Sep 2021 15:43:33 +0200 Subject: [PATCH 08/22] [FIX] project: remove the set a cover button in project sharing Before this commit, we add the Set a cover image in the kanban view of task for portal user in project sharing feature. However, the portal user has not access to `ir.attachment` model. So, those users cannot selects a cover image for a task. This commit removes this button in project sharing feature. task-2633229 closes #77156 X-original-commit: 2f8bb52c942416528de4d7d95c53e0ac1c99bf5b --- addons/project/views/project_sharing_views.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/project/views/project_sharing_views.xml b/addons/project/views/project_sharing_views.xml index be37ff64aa4..c299b7854b4 100644 --- a/addons/project/views/project_sharing_views.xml +++ b/addons/project/views/project_sharing_views.xml @@ -71,7 +71,8 @@ -
+
- + From 9089dfef5e13eda76314577cf96edb34d246da10 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Wed, 22 Sep 2021 11:45:30 +0200 Subject: [PATCH 12/22] [FIX] project: allow edit priority task in project sharing Before this commit, the `priority` field in task was in readonly in project sharing feature. This commit allows the `priority` field in task be edited by a portal user in project sharing. task-2633229 closes #77156 X-original-commit: 62572e17d6cd62f16287d530c247dbe9b8501e0c --- addons/project/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 1325f96d586..11205853f08 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -38,7 +38,6 @@ PROJECT_TASK_READABLE_FIELDS = { 'company_id', 'displayed_image_id', 'display_name', - 'priority', 'portal_user_names', } @@ -54,6 +53,7 @@ PROJECT_TASK_WRITABLE_FIELDS = { 'kanban_state', 'child_ids', 'parent_id', + 'priority', } class ProjectTaskType(models.Model): From c0c1af4ca2fddbcc7d9309c3e3203f292319a842 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Wed, 22 Sep 2021 12:38:11 +0200 Subject: [PATCH 13/22] [FIX] project: see custom kanban state label Before this commit, the user could only see the default kanban state label in kanban state label. That is, "Ready", "Blocked" and "Normal". This commit allows to see the custom kanban state label in project sharing feature. task-2633229 closes #77156 X-original-commit: a9a884cfe1f8328ae71edc93832e4c4408d9c581 --- addons/project/models/project.py | 3 +++ addons/project/views/project_sharing_views.xml | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 11205853f08..0e32155746c 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -39,6 +39,9 @@ PROJECT_TASK_READABLE_FIELDS = { 'displayed_image_id', 'display_name', 'portal_user_names', + 'legend_normal', + 'legend_blocked', + 'legend_done', } PROJECT_TASK_WRITABLE_FIELDS = { diff --git a/addons/project/views/project_sharing_views.xml b/addons/project/views/project_sharing_views.xml index ab1893a5e9f..2b6e452add4 100644 --- a/addons/project/views/project_sharing_views.xml +++ b/addons/project/views/project_sharing_views.xml @@ -43,6 +43,9 @@ + + + @@ -132,6 +135,9 @@ + + + @@ -161,6 +167,9 @@ + + +
From aeac9052b8dcb0f688f5d5fca160f6524134dcb3 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Wed, 22 Sep 2021 17:37:53 +0200 Subject: [PATCH 14/22] [FIX] portal: get all options when we reload the chatter Before this commit, we use the defaultOptions and the options passed in parameter of the `_setOptions` method, but we could have any unupdated options in the `this.options`. This commit creates a new object with the defaultOptions and the options containing in `this.options` before update this object with `options` given in parameter to have the new `this.options`. task-2633229 closes #77156 X-original-commit: 5d1a36bdd530d4037d4f29dc607907d79d18dcc6 --- addons/portal/static/src/js/portal_chatter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/portal/static/src/js/portal_chatter.js b/addons/portal/static/src/js/portal_chatter.js index 0f379460d06..ec399e5075d 100644 --- a/addons/portal/static/src/js/portal_chatter.js +++ b/addons/portal/static/src/js/portal_chatter.js @@ -122,7 +122,7 @@ var PortalChatter = publicWidget.Widget.extend({ */ _setOptions: function (options) { // underscorize the camelcased option keys - const defaultOptions = { + const defaultOptions = Object.assign({ 'allow_composer': true, 'display_composer': false, 'csrf_token': odoo.csrf_token, @@ -137,7 +137,7 @@ var PortalChatter = publicWidget.Widget.extend({ 'pid': false, 'domain': [], 'two_columns': false, - }; + }, this.options || {}); this.options = Object.entries(options).reduce( (acc, [key, value]) => { From adf3aca403a39e49e79b5c2a0275aef6e3bf8273 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 23 Sep 2021 16:05:56 +0200 Subject: [PATCH 15/22] [FIX] project: use task in sudo for classic portal task view Before this commit, when the portal user has access to a project and a task has a customer who is not in the same company than the portal user, the portal user has a AccessError when he wants to consult this task. This commit uses the task in sudo to have the same information shown in /my/task/. Steps to reproduce: ------------------ 1. Share in readonly mode a project to the portal user (with visibility set to 'portal') 2. Create a task in this project and set a Customer A (a customer who has not the same company than the portal user). 3. Log in as portal user (Joel Willis). 4. Go to '/my/projects' and select the project shared. 5. Select the task created. Actual Behaviour: ---------------- AccessError exception is displayed because the portal user has no access to partner in other company than his yours. Expected Behaviour: ------------------ Display the task portal form view like the one shown in /my/task/. task-2633229 closes #77156 X-original-commit: 3b0d6d0cef73baa5b5f235c3518c8bd698c81e21 --- addons/project/controllers/portal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/project/controllers/portal.py b/addons/project/controllers/portal.py index 7ff3097d604..63cd3bd2a22 100644 --- a/addons/project/controllers/portal.py +++ b/addons/project/controllers/portal.py @@ -210,9 +210,9 @@ class ProjectCustomerPortal(CustomerPortal): Task = request.env['project.task'] if access_token: Task = Task.sudo() - task = Task.search([('project_id', '=', project_id), ('id', '=', task_id)], limit=1) - task.sudo().attachment_ids.generate_access_token() - values = self._task_get_page_view_values(task, access_token, project=project_sudo, **kw) + task_sudo = Task.search([('project_id', '=', project_id), ('id', '=', task_id)], limit=1).sudo() + task_sudo.attachment_ids.generate_access_token() + values = self._task_get_page_view_values(task_sudo, access_token, project=project_sudo, **kw) values['project'] = project_sudo return request.render("project.portal_my_task", values) From 614657d799cbc0cb4da7c6a049fb518c4e5a312a Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 30 Sep 2021 14:16:04 +0200 Subject: [PATCH 16/22] [FIX] project: show 'Assign To Me' only if the user is not assigned Before this commit, when the task has a user assigned to a task and the current user wants to assign himself to this task. He cannot see the 'Assign To Me' button because this button is only visible if the `user_ids` field is empty. This commit changes the visibility of this button to show this button only if the current user is not yet assigned to the task. task-2633229 closes #77156 X-original-commit: cfba241bada2b3690b4303b7e01747301925d162 --- addons/project/views/project_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 86acea86a1b..3b802f21ad0 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -809,7 +809,7 @@
@@ -1100,7 +1100,7 @@
Private -
+
From 95c0fe5729c05568b65d2e801e7b9c09fb2cec80 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 7 Oct 2021 20:30:43 +0200 Subject: [PATCH 17/22] [FIX] project: favorite menu in project sharing Before this commit, when the collaborator clicks on the favorite menu, he has a traceback because the 'spreadsheet' service is not available. Since we don't want to use this service and we just want the menu item to save the current as favorite. This commit override the favorite menu to remove the registry items to add the menu item and we just add the one we want. task-2633229 closes #77156 X-original-commit: d970c13494db2c3e085155b7855b656fbbe26467 --- .../components/favorite_menu_registry.js | 35 ++++++++++++++++++ .../static/src/project_sharing/main.js | 2 ++ .../tests/tours/project_sharing_tour.js | 36 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 addons/project/static/src/project_sharing/components/favorite_menu_registry.js diff --git a/addons/project/static/src/project_sharing/components/favorite_menu_registry.js b/addons/project/static/src/project_sharing/components/favorite_menu_registry.js new file mode 100644 index 00000000000..13b05bf1556 --- /dev/null +++ b/addons/project/static/src/project_sharing/components/favorite_menu_registry.js @@ -0,0 +1,35 @@ +/** @odoo-module **/ + +import FavoriteMenuLegacy from 'web.FavoriteMenu'; +import CustomFavoriteItemLegacy from 'web.CustomFavoriteItem'; +import { registry } from "@web/core/registry"; + + +/** + * Remove all components contained in the favorite menu registry except the CustomFavoriteItem + * component for only the project sharing feature. + */ +export function prepareFavoriteMenuRegister() { + let customFavoriteItemKey = 'favorite-generator-menu'; + const keys = FavoriteMenuLegacy.registry.keys().filter(key => key !== customFavoriteItemKey); + FavoriteMenuLegacy.registry = Object.assign(FavoriteMenuLegacy.registry, { + map: {}, + _scoreMapping: {}, + _sortedKeys: null, + }); + FavoriteMenuLegacy.registry.add(customFavoriteItemKey, CustomFavoriteItemLegacy, 0); + // notify the listeners, we keep only one key in this registry. + for (const key of keys) { + for (const callback of FavoriteMenuLegacy.registry.listeners) { + callback(key, undefined); + } + } + + customFavoriteItemKey = 'custom-favorite-item'; + const favoriteMenuRegistry = registry.category("favoriteMenu"); + for (const [key, _] of favoriteMenuRegistry.getEntries()) { + if (key !== customFavoriteItemKey) { + favoriteMenuRegistry.remove(key); + } + } +} diff --git a/addons/project/static/src/project_sharing/main.js b/addons/project/static/src/project_sharing/main.js index 61458f6992c..9af1f6eeb8b 100644 --- a/addons/project/static/src/project_sharing/main.js +++ b/addons/project/static/src/project_sharing/main.js @@ -1,5 +1,7 @@ /** @odoo-module **/ import { startWebClient } from '@web/start'; import { ProjectSharingWebClient } from './project_sharing'; +import { prepareFavoriteMenuRegister } from './components/favorite_menu_registry'; +prepareFavoriteMenuRegister(); startWebClient(ProjectSharingWebClient); diff --git a/addons/project/static/tests/tours/project_sharing_tour.js b/addons/project/static/tests/tours/project_sharing_tour.js index ea9fb09c261..b744f44f943 100644 --- a/addons/project/static/tests/tours/project_sharing_tour.js +++ b/addons/project/static/tests/tours/project_sharing_tour.js @@ -69,6 +69,24 @@ tour.register('project_sharing_tour', { }, { trigger: 'ol.breadcrumb > li.o_back_button > a:contains(Project Sharing)', content: 'Go back to the kanban view', +}, { + trigger: '.o_filter_menu > button', + content: 'click on filter menu in the search view', +}, { + trigger: '.o_filter_menu > .dropdown-menu > .dropdown-item:first-child', + content: 'click on the first item in the filter menu', +}, { + trigger: '.o_group_by_menu > button', + content: 'click on group by menu in the search view', +}, { + trigger: '.o_group_by_menu > .dropdown-menu > .dropdown-item:first-child', + content: 'click on the first item in the group by menu', +}, { + trigger: '.o_favorite_menu > button', + content: 'click on the favorite menu in the search view', +}, { + trigger: '.o_favorite_menu .o_add_favorite > button', + content: 'click to "save current search" button in favorite menu', }, { trigger: 'button.o_switch_view.o_list', content: 'Go to the list view', @@ -109,6 +127,24 @@ tour.register('portal_project_sharing_tour', { }, { trigger: 'ol.breadcrumb > li.o_back_button > a:contains(Project Sharing)', content: 'Go back to the kanban view', +}, { + trigger: '.o_filter_menu > button', + content: 'click on filter menu in the search view', +}, { + trigger: '.o_filter_menu > .dropdown-menu > .dropdown-item:first-child', + content: 'click on the first item in the filter menu', +}, { + trigger: '.o_group_by_menu > button', + content: 'click on group by menu in the search view', +}, { + trigger: '.o_group_by_menu > .dropdown-menu > .dropdown-item:first-child', + content: 'click on the first item in the group by menu', +}, { + trigger: '.o_favorite_menu > button', + content: 'click on the favorite menu in the search view', +}, { + trigger: '.o_favorite_menu .o_add_favorite > button', + content: 'click to "save current search" button in favorite menu', }, { trigger: 'button.o_switch_view.o_list', content: 'Go to the list view', From f7bcc14d254ff5f1da4792cd51e916d831b9d23d Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 14 Oct 2021 17:25:47 +0200 Subject: [PATCH 18/22] [FIX] hr_timesheet: show total_hours and progress if allow_timesheets Before this commit, those columns are not invisible if the project has not allow_timesheets enabled (or not allow_subtasks for "Total Hours" field) in list view of project sharing feature. This commit changes the attrs of those field to hide the column if the domain is satisfied. task-2633229 closes #77156 X-original-commit: 3856024d037a86a07703cc492f7cc41be93169de --- addons/hr_timesheet/views/project_sharing_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/views/project_sharing_views.xml b/addons/hr_timesheet/views/project_sharing_views.xml index 1656a32a798..7a9798821a7 100644 --- a/addons/hr_timesheet/views/project_sharing_views.xml +++ b/addons/hr_timesheet/views/project_sharing_views.xml @@ -155,8 +155,8 @@ - - + + From c2e81483688152b9c3fd5960e980ef0ec36ac1ed Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Fri, 15 Oct 2021 11:41:23 +0200 Subject: [PATCH 19/22] [FIX] hr_timesheet: fix access error when load_views in project sharing Before this commit, when the user chooses to encode in 'Days', the timesheets, when a collaborator accesses to the project sharing feature for a shared project. This collaborator has an access error because he does not have any access to `uom.uom` of the current company. Indeed, we use this uom to change the label of `unit_amount` field for timesheets linked to this project shared. This commit fetches the name of the encoding for the current company in sudo to change the label of `unit_amount` field of timesheets during the load_views of project sharing feature. task-2633229 closes #77156 X-original-commit: 575315744a31a975208c82f72403ecebf3585f37 --- addons/hr_timesheet/models/hr_timesheet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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') From d3b8d1fd31ea6e1d57eabc1db0792c15c461edaf Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Tue, 28 Sep 2021 14:19:15 +0200 Subject: [PATCH 20/22] [FIX] project: remove 'Share with all users' checkbox in project sharing Before this commit, the portal user could see the checkbox in search view to share his favorite item with all users. This action is not authorize in project sharing feature and should be removed. This commit removes this checkbox to avoid the portal user to share his favorite item with others users. task-2633229 closes #77156 X-original-commit: 19b38074dd8bfe4d8347db31f946beeb2850d453 --- addons/project/__manifest__.py | 1 + .../search/favorite_menu/custom_favorite_item.xml | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 addons/project/static/src/project_sharing/search/favorite_menu/custom_favorite_item.xml diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 5d9fc081dd2..9b5d8bf3740 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -115,6 +115,7 @@ 'web/static/src/legacy/js/public/public_widget.js', 'portal/static/src/js/portal_chatter.js', 'portal/static/src/js/portal_composer.js', + 'project/static/src/project_sharing/search/favorite_menu/custom_favorite_item.xml', 'project/static/src/project_sharing/**/*.js', 'project/static/src/scss/project_sharing/*', 'web/static/src/start.js', diff --git a/addons/project/static/src/project_sharing/search/favorite_menu/custom_favorite_item.xml b/addons/project/static/src/project_sharing/search/favorite_menu/custom_favorite_item.xml new file mode 100644 index 00000000000..e03c1be7bc8 --- /dev/null +++ b/addons/project/static/src/project_sharing/search/favorite_menu/custom_favorite_item.xml @@ -0,0 +1,8 @@ + + + + + + + + From fbac7f191db31c2870c294d9190196c9dfe7e2b7 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Wed, 29 Sep 2021 08:29:04 +0200 Subject: [PATCH 21/22] [FIX] project: exclude project sharing assets qweb from `web.assets_qweb` Before this commit, we import all xml in project module. The problem is the ones for project sharing should not be included in `web.assets_qweb`. This commit excludes the project sharing assets from `web.assets_qweb`. task-2633229 closes #77156 X-original-commit: 21e21d7956d6de1775f4230060cdff7c39015bbc --- addons/project/__manifest__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 9b5d8bf3740..4ce0c2ef4cc 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -87,7 +87,9 @@ 'project/static/src/js/portal_rating.js', ], 'web.assets_qweb': [ - 'project/static/src/**/*.xml', + 'project/static/src/xml/**/*', + 'project/static/src/burndown_chart/**/*.xml', + 'project/static/src/project_control_panel/**/*.xml', ], 'web.qunit_suite_tests': [ 'project/static/tests/burndown_chart_tests.js', From 708861ed3d0644d389855139230f1968078226b0 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 28 Oct 2021 11:03:09 +0200 Subject: [PATCH 22/22] [IMP] project: manage column_invisible in project sharing list Before this commit, it was impossible to to hide a column when the timesheets or subtasks features are not enabled to the project shared. This commit manages the column_invisible for the list view in project sharing to compute the domain in this modifiers. We assume all tasks displayed in project sharing are linked to a project shared. task-2633229 closes #77156 X-original-commit: ab2b5d1fd1f09d804ab410bc326cfebf26d5a7c6 --- .../src/project_sharing/views/list/view.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/addons/project/static/src/project_sharing/views/list/view.js b/addons/project/static/src/project_sharing/views/list/view.js index 1f70f9c5f01..843f7861303 100644 --- a/addons/project/static/src/project_sharing/views/list/view.js +++ b/addons/project/static/src/project_sharing/views/list/view.js @@ -10,5 +10,37 @@ export default ListView.extend({ init: function (viewInfo, params) { return this._super(viewInfo, {...params, hasSelectors: false}); - } + }, + getRenderer (parent, state) { + const columnInvisibleFields = {}; + for (const child of this.arch.children) { + if (child.attrs && child.attrs.modifiers && child.attrs.modifiers.column_invisible) { + columnInvisibleFields[child.attrs.name] = child.attrs.modifiers.column_invisible; + } + } + this.rendererParams.columnInvisibleFields = Object.entries(columnInvisibleFields).reduce((acc, entry) => { + const [fieldName, domains] = entry; + if (domains instanceof Array && state.data.length) { + const record = state.data[0]; + const data = Object.entries(record.data).reduce((acc, entry) => { + const [fieldName, value] = entry; + const field = record.fields[fieldName]; + if (field.type === 'one2many' || field.type === 'many2many') { + if (value instanceof Object && value.type === 'list') { + acc[fieldName] = value.id; + } + } + return acc; + }, record.data); + if (Object.keys(data).length) { + // We assume the field in this domain is a related to the project shared. + acc[fieldName] = this.model._evalModifiers({ ...record, data }, { column_invisible: domains }).column_invisible; + } + } else { + acc[fieldName] = domains; + } + return acc; + }, {}); + return this._super(parent, state); + }, });