(Introduced in 16.3, 86c6266)
--- ISSUE
From there, partner_ids and partner_all_ids m2m fields became computed
fields in order to return only active records as we read them from
the slide.channel.partner table, not checking the active field of that
table (not supported by framework).
Ir rules of records check if current user's partner is inside partner_ids,
or partner_all_ids of a given course. (joined the course for partner_ids,
invited or joined the course for partner_all_ids)
The issue is that all ir rules searching on these fields lead to very
slow loading of slides (channel, slide, homepage) and forum pages (as
soon as we have a forum linked to a course). This comes from the fact
that in some templates, we read records and evaluate rules on the spot,
in python. (for instance tags of courses on homepage)
As some courses have tens of thousands of attendees, this evaluation is
very slow in python, and there is no quick solution at framework level.
Therefore, computing thousands of partners for each access rule linked
to a course is too slow.
--- SOLUTION
The existing fields is_member and is_member_invited are used inside ir
rules instead. _search methods are added and we check whether course
is inside courses of current user's partner ones. It improved all times
a lot, see BENCHMARK below.
Tests already exist to assert the search methods indirectly.
--- LOCAL BENCHMARK (16.3) - IntelCore i5-8265U CPU 1.60GHz - Firefox
ROUTE BEFORE (s) AFTER (s)
/slides 5 <0.15
/slides/all 7.6 <0.15
/slides/course_c 4.2 <0.2
/forum 5.5 <0.15
/forum/forum_c 6 <0.25
/forum/forum_c/post_y 4.4 <0.25
/forum/forum_c/post_y/edit_answer 2.5 + 2.5 <0.3 total
/forum/forum_c/post_y/edit 2.8 <0.2
/forum/forum_c/post_y/reply 3 (+6 post) <0.35 total
/profile/user/id 2.3 <0.4
DETAILS
- course_c: 43k attendees
- forum_c: forum of course_c
- post_y: 2-3 answers
- logged user: 'portal', with 7 courses
- deactivated GC cron as many populated invited attendees were
to be removed, and it can take a lot of time
POPULATIONS
- 20k forum.forum (avg 2 answers)
- 20k mail.message (about 2 answers per post)
- 10 forum.forum (+20 on courses)
- 20 slide.channel (half 'members' visibility)
- 300k slide.channel.partner
- 'large' for other models
--- LINKS
UPG PR: odoo/upgrade#5246
Task-3444633
closesodoo/odoo#139104
X-original-commit: 019d9d4808994cd819d13fab2d6ddfdffeb621e7
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>