diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index f504ecc03fd6ca28f6aaacab5f50261fb1cae2bc..28b53c89dec383b4a0ad2272dbc1d005769765ec 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -1,7 +1,6 @@ # -*- 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): diff --git a/addons/website_slides/views/website_slides_templates_profile.xml b/addons/website_slides/views/website_slides_templates_profile.xml index 8fbfd413f554ba316962ea94ec6024707aebb1f0..262c95a77170ecce75e3561d5c513f62d2c10baa 100644 --- a/addons/website_slides/views/website_slides_templates_profile.xml +++ b/addons/website_slides/views/website_slides_templates_profile.xml @@ -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>