[FIX] website_slides_survey : fix certification badges display

Before this commit, when going to /profile/ranks_badges on the website,
an error 500 happened when it had to show certification badges.
This is because the certification badges use the "state" field of their linked
survey to check if it is still open.
This field has been removed in 15.0, where the active state of the survey is
used to know if it is still used instead of a state.  When archiving a
certification survey, their linked badge is automatically archived as well,
so there is no need for that line anymore.

opw-3373973

closes odoo/odoo#126834

X-original-commit: 6d99542da6bf7881043bdc204c409d64cf7672c1
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
Leloup Loïc (lole)
2023-06-30 01:32:52 +02:00
parent 8fc62fbdb4
commit 65ae78b95d
@@ -148,9 +148,8 @@ class WebsiteSlidesSurvey(WebsiteSlides):
# 2. sort by granted users (done here, and not in search directly, because non stored field)
certification_badges = certification_badges.sorted("granted_users_count", reverse=True)
# 3. Remove certification badge from badges and keep only certification badge linked to opened survey
# 3. Remove certification badge from badges
badges = values['badges'] - certification_badges
certification_badges = certification_badges.filtered(lambda b: b.survey_id.state == 'open')
# 4. Getting all course url for each badge
certification_slides = request.env['slide.slide'].sudo().search([('survey_id', 'in', certification_badges.mapped('survey_id').ids)])