Skip to content

Commit

Permalink
[FIX] project: project grouped by stages now respects the pagination
Browse files Browse the repository at this point in the history
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#192955

X-original-commit: f4c41aa
Signed-off-by: Xavier Bol (xbo) <[email protected]>
  • Loading branch information
hubvd committed Jan 13, 2025
1 parent 671a321 commit 3d17e79
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/project/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 3d17e79

Please sign in to comment.