diff options
| author | Aurélien Warnon <awa@odoo.com> | 2019-04-30 08:27:56 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-05-03 09:43:27 +0000 |
| commit | bf3ed3fc7c2cbfacd2d00e9fd2dbc2edb8ce3c29 (patch) | |
| tree | c804f71130b542139340d36bd62e0a06f553f875 /addons | |
| parent | 8af1fe54adb54c915d282601353ddd1ac0232be2 (diff) | |
[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 534822e54c44ba9048de2d8b22675d1adefeaf80
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website_slides/models/slide_channel.py | 3 | ||||
| -rw-r--r-- | addons/website_slides/views/website_slides_templates_profile.xml | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index f504ecc03fd..28b53c89dec 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 8fbfd413f55..262c95a7717 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> |
