Skip to content
Snippets Groups Projects
Commit bf3ed3fc authored by Aurélien Warnon's avatar Aurélien Warnon Committed by Thibault Delavallée
Browse files

[FIX] website_slides: fix courses completion on user profile page

This commit fixes the courses (slide.channel) completion displayed on the user
profile page. It uses the number of completed slides instead of the percentage
of completion. This is due to the completion field having been updated
recently to store number of completed slides instead of a computed percentage
for performances reasons [1]

Commit linked to task ID 1978530 (fixes linked to internal testing).

[1] See 534822e5
parent 8af1fe54
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import math
import uuid
from odoo import api, fields, models, tools, _
......@@ -237,7 +236,7 @@ class Channel(models.Model):
for record in self:
completed, completion = mapped_data.get(record.id, (False, 0))
record.completed = completed
record.completion = math.ceil(100.0 * completion / (record.total_slides or 1))
record.completion = round(100.0 * completion / (record.total_slides or 1))
@api.depends('upload_group_ids', 'user_id')
def _compute_can_upload(self):
......
......@@ -33,6 +33,8 @@
<template id="display_course">
<div class="row">
<div class="col-12 col-lg-6" t-foreach="courses" t-as="course">
<!-- We cannot use the course.channel_id.completion here since the slide.channel.partners are fetched in sudo mode, recompute it -->
<t t-set="channel_completion" t-value="round(100.0 * course.completion / (course.channel_id.total_slides or 1))" />
<div class="card mb-2">
<div class="card-body o_wprofile_slides_course_card_body p-0 d-flex"
t-attf-onclick="location.href='/slides/#{slug(course.channel_id)}';">
......@@ -59,9 +61,9 @@
<div class="d-flex align-items-center">
<div class="progress flex-grow-1" style="height:0.5em">
<div class="progress-bar bg-primary" t-att-style="'width: '+ str(course.completion)+'%'"/>
<div class="progress-bar bg-primary" t-att-style="'width: '+ str(channel_completion)+'%'"/>
</div>
<small class="font-weight-bold pl-2"><span t-field="course.completion"/> %</small>
<small class="font-weight-bold pl-2"><span t-esc="channel_completion"/> %</small>
</div>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment