Skip to content
Snippets Groups Projects
Commit e4a3c982 authored by thsh-odoo's avatar thsh-odoo
Browse files

[FIX] website_slides: inaccurate completion time

How to reproduce the bug
=========================.
1. Open e-Learning.
2. Create a section.
3. Add a content in the created section and change the default duration .
-> New duration is not set and it is taking the default duration only

Technical
=========
https://github.com/odoo/odoo/commit/7b7fdf8f2771840797e1d416a8275ba3666ab542


This commit introduce the feature to set default time for the content in the
backend if user put the Duration field empty for that content but because of
the extra 'not' in the condition it was always getting true so every time
default value is stored and if completion_time is not there then it is set
to 0.

After this Commit
==================
Now whatever duration user will put, it will be set and if completion_time is
not given then it will give us the default time.

Task-3340462

closes odoo/odoo#135334

X-original-commit: 1c470b65bca48c2ac660fda919be7b8fc6e3990f
Signed-off-by: default avatarStéphane Debauche (std) <std@odoo.com>
parent 951dee23
No related branches found
No related tags found
No related merge requests found
......@@ -641,7 +641,7 @@ class Slide(models.Model):
# only update keys that are not set in the incoming vals
slide.update({key: value for key, value in slide_metadata.items() if key not in vals.keys()})
if not 'completion_time' not in vals:
if 'completion_time' not in vals:
slide._on_change_document_binary_content()
if slide.is_published and not slide.is_category:
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.website_slides.tests import common as slides_common
from odoo.exceptions import UserError
from odoo.tests.common import users
from unittest.mock import patch
class TestSlidesManagement(slides_common.SlidesCase):
......@@ -174,6 +174,38 @@ class TestSlidesManagement(slides_common.SlidesCase):
self.assertFalse(self.channel.exists(),
"Should have deleted channel along with the slides even if there are slides with quiz and participant(s)")
def test_default_completion_time(self):
"""Verify whether the system calculates the completion time when it is not specified,
but if the user does provide a completion time, the default time should not be applied."""
def _get_completion_time_pdf(*args, **kwargs):
return 13.37
with patch(
'odoo.addons.website_slides.models.slide_slide.Slide._get_completion_time_pdf',
new=_get_completion_time_pdf
):
slides_1 = self.env['slide.slide'].create({
'name': 'Test_Content',
'slide_category': 'document',
'is_published': True,
'is_preview': True,
'document_binary_content': 'c3Rk',
'channel_id': self.channel.id,
})
slides_2 = self.env['slide.slide'].create({
'name': 'Test_Content',
'slide_category': 'document',
'is_published': True,
'is_preview': True,
'document_binary_content': 'c3Rk',
'channel_id': self.channel.id,
'completion_time': 123,
})
self.assertEqual(13.37, slides_1.completion_time)
self.assertEqual(123.0, slides_2.completion_time)
class TestSequencing(slides_common.SlidesCase):
......
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