From 3d17e794948e7100e05830f86172f7106705666e Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Mon, 6 Jan 2025 10:31:58 +0000 Subject: [PATCH] [FIX] project: project grouped by stages now respects the pagination Steps to reproduce ================== - Open any project - Create many project stages (80+) - Switch to the list view - Group by stage - Switch to to next page => The pager keeps increasing Cause of the issue ================== `stage_id` has a group_expand: `_read_group_stage_ids` This method is used to include empty stages in the result for the kanban view, so that we can drag tasks to an empty stage. Solution ======== Add a context key `project_kanban` and only add empty stages in that case. opw-4408061 closes odoo/odoo#192955 X-original-commit: f4c41aa2836cd937cd476e50dcd494fc8549476a Signed-off-by: Xavier Bol (xbo) --- addons/project/models/project_task.py | 2 +- .../project_sharing/views/kanban/kanban_view.js | 16 ++++++++++++++++ .../project_task_kanban_model.js | 10 +++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 addons/project/static/src/project_sharing/views/kanban/kanban_view.js diff --git a/addons/project/models/project_task.py b/addons/project/models/project_task.py index d87784778b777..24ec1e0c7395a 100644 --- a/addons/project/models/project_task.py +++ b/addons/project/models/project_task.py @@ -113,7 +113,7 @@ def _default_company_id(self): @api.model def _read_group_stage_ids(self, stages, domain, order): search_domain = [('id', 'in', stages.ids)] - if 'default_project_id' in self.env.context and not self._context.get('subtask_action'): + if 'default_project_id' in self.env.context and not self._context.get('subtask_action') and 'project_kanban' in self.env.context: search_domain = ['|', ('project_ids', '=', self.env.context['default_project_id'])] + search_domain stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID) diff --git a/addons/project/static/src/project_sharing/views/kanban/kanban_view.js b/addons/project/static/src/project_sharing/views/kanban/kanban_view.js new file mode 100644 index 0000000000000..2f195817c8b43 --- /dev/null +++ b/addons/project/static/src/project_sharing/views/kanban/kanban_view.js @@ -0,0 +1,16 @@ +/** @odoo-module */ + +import { kanbanView } from "@web/views/kanban/kanban_view"; +import { RelationalModel } from "@web/model/relational_model/relational_model"; + +export class ProjectSharingTaskKanbanModel extends RelationalModel { + async _webReadGroup(config, firstGroupByName, orderBy) { + config.context = { + ...config.context, + project_kanban: true, + }; + return super._webReadGroup(...arguments); + } +} + +kanbanView.Model = ProjectSharingTaskKanbanModel; diff --git a/addons/project/static/src/views/project_task_kanban/project_task_kanban_model.js b/addons/project/static/src/views/project_task_kanban/project_task_kanban_model.js index 84d8b99547f75..d2856e1da9383 100644 --- a/addons/project/static/src/views/project_task_kanban/project_task_kanban_model.js +++ b/addons/project/static/src/views/project_task_kanban/project_task_kanban_model.js @@ -8,6 +8,14 @@ export class ProjectTaskKanbanDynamicGroupList extends RelationalModel.DynamicGr } } -export class ProjectTaskKanbanModel extends RelationalModel {} +export class ProjectTaskKanbanModel extends RelationalModel { + async _webReadGroup(config, firstGroupByName, orderBy) { + config.context = { + ...config.context, + project_kanban: true, + }; + return super._webReadGroup(...arguments); + } +} ProjectTaskKanbanModel.DynamicGroupList = ProjectTaskKanbanDynamicGroupList;