Skip to content
Snippets Groups Projects
Commit 01137414 authored by Jason Van Malder's avatar Jason Van Malder
Browse files

[FIX] mail, web: fix activities count when they are uniquified

Issue

    - Install CRM for example
    - Add 41 leads
    - Create an activity on each of them

    Everything ok, load more shows up

    - Add another activity on one of them

    Load more doesn't shows up

Cause

    The uniquify method:
    https://github.com/odoo/odoo/blob/saas-12.3/odoo/models.py#L4187:#L4191



    Consider the second activity as a duplicate and removes it.
    So, in `web_search_read`:
    `len(records) <= limit` is `True` and we ignore all
    the others records

Solution

    Add `force_search_count` in the context when using this action
    to avoid uniquify to falsify the records length.

    I added the tree view for this action too. It improves UX.

OPW-2165455

closes odoo/odoo#43149

X-original-commit: 13ec3503fbfb5d3d2b1e824059737bd866a3a9f4
Signed-off-by: default avatarJason Van Malder <jvm-odoo@users.noreply.github.com>
parent b1075b36
Branches
Tags
No related merge requests found
......@@ -137,11 +137,14 @@ var ActivityMenu = Widget.extend({
} else {
context['search_default_activities_' + data.filter] = 1;
}
// Necessary because activity_ids of mail.activity.mixin has auto_join
// So, duplicates are faking the count and "Load more" doesn't show up
context['force_search_count'] = 1;
this.do_action({
type: 'ir.actions.act_window',
name: data.model_name,
res_model: data.res_model,
views: [[false, 'kanban'], [false, 'form']],
views: [[false, 'kanban'], [false, 'list'], [false, 'form']],
search_view_id: [false],
domain: [['activity_user_id', '=', session.uid]],
context:context,
......
......@@ -126,6 +126,7 @@ QUnit.test('activity menu widget: activity menu with 3 records', async function
// case 1: click on "late"
context = {
force_search_count: 1,
search_default_activities_overdue: 1,
};
await testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
......@@ -134,18 +135,21 @@ QUnit.test('activity menu widget: activity menu with 3 records', async function
assert.doesNotHaveClass(activityMenu.$el, 'show', 'ActivityMenu should be closed');
// case 2: click on "today"
context = {
force_search_count: 1,
search_default_activities_today: 1,
};
await testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
await testUtils.dom.click(activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='today']"));
// case 3: click on "future"
context = {
force_search_count: 1,
search_default_activities_upcoming_all: 1,
};
await testUtils.dom.click(activityMenu.$('.dropdown-toggle'));
await testUtils.dom.click(activityMenu.$(".o_activity_filter_button[data-model_name='Issue'][data-filter='upcoming_all']"));
// case 4: click anywere else
context = {
force_search_count: 1,
search_default_activities_overdue: 1,
search_default_activities_today: 1,
};
......
......@@ -39,7 +39,7 @@ class Base(models.AbstractModel):
'length': 0,
'records': []
}
if limit and len(records) == limit:
if limit and (len(records) == limit or self.env.context.get('force_search_count')):
length = self.search_count(domain)
else:
length = len(records) + offset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment