[FIX] mail: fix activity view pager
This solves the following problem: - Add 150 records with 2 activities each (ex. A call and a to do) - Go to the activity view (ex.: event through the systray) and clear filter - Only 50 of the 150 records are displayed (instead of 100) - Going to the next page, only 2 are displayed (instead of ~50) (will depends on the data already present) Technical notes: Not all activities were displayed because the search limit was applied on the activity search instead of searching all activity related to the records. The method fetchActivityData was doing half of the job because it was not assigning the activity data fetch on the server to the instance variable activityData, which was causing strange behavior when clicking on next page. To simplify and correct the code, that logic has been moved to that method instead of relying on the caller to do that assignation. Task-3508744 closes odoo/odoo#135651 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -581,13 +581,13 @@ class MailActivity(models.Model):
|
||||
@api.model
|
||||
def get_activity_data(self, res_model, domain, limit=None, offset=0):
|
||||
activity_domain = [('res_model', '=', res_model)]
|
||||
if domain:
|
||||
res = self.env[res_model].search(domain)
|
||||
if domain or limit or offset:
|
||||
res = self.env[res_model].search(domain or [], limit=limit, offset=offset)
|
||||
activity_domain.append(('res_id', 'in', res.ids))
|
||||
grouped_activities = self.env['mail.activity']._read_group(
|
||||
activity_domain,
|
||||
['res_id', 'activity_type_id'],
|
||||
['id:array_agg', 'date_deadline:min', '__count'], limit=limit, offset=offset)
|
||||
['id:array_agg', 'date_deadline:min', '__count'])
|
||||
# filter out unreadable records
|
||||
if not domain:
|
||||
res_ids = tuple(res_id for res_id, *_ in grouped_activities)
|
||||
|
||||
@@ -47,8 +47,7 @@ export class ActivityController extends Component {
|
||||
limit: limit,
|
||||
total: count,
|
||||
onUpdate: async (params) => {
|
||||
await this.model.root.load(params);
|
||||
this.model.fetchActivityData(params);
|
||||
await Promise.all([this.model.root.load(params), this.model.fetchActivityData(params)]);
|
||||
},
|
||||
updateTotal: hasLimitedCount ? () => this.model.root.fetchCount() : undefined,
|
||||
};
|
||||
|
||||
@@ -11,14 +11,11 @@ export class ActivityModel extends RelationalModel {
|
||||
if (params && "groupBy" in params) {
|
||||
params.groupBy = [];
|
||||
}
|
||||
const prom = this.fetchActivityData(params).then((data) => {
|
||||
this.activityData = data;
|
||||
});
|
||||
await Promise.all([prom, super.load(params)]);
|
||||
await Promise.all([this.fetchActivityData(params), super.load(params)]);
|
||||
}
|
||||
|
||||
fetchActivityData(params) {
|
||||
return this.orm.call("mail.activity", "get_activity_data", [], {
|
||||
async fetchActivityData(params) {
|
||||
this.activityData = await this.orm.call("mail.activity", "get_activity_data", [], {
|
||||
res_model: this.config.resModel,
|
||||
domain: params.domain || this.env.searchModel._domain,
|
||||
limit: params.limit || this.initialLimit,
|
||||
|
||||
Reference in New Issue
Block a user