[FIX] website_slides: fix concurrency traceback

- Prior to this commit, slide content of type document or presentation is
  having src as '/slides/embed' and that controller tries to set slide as
  viewed. Along with this, for few slide types (including document and
  presentation) and for logged in user, it will try to set slide as completed
  once slide rendering is done with help of method `_setCompleted`, without
  waiting for the iframe to be loaded. This means, the controller called from
  the src of iFrame and the above method both tries to update same 'slide_slide'
  table at the same time, resulting into concurrency error.

- This commit fixes the issue by marking the slide as completed (with help
  of method `_setCompleted`) only after the iFrame is loaded, avoiding the
  concurrent updation of 'slide.slide' table.

TaskID 2265863
Closes https://github.com/odoo/odoo/pull/52918

closes odoo/odoo#59391

X-original-commit: c5f406c8cbf43c56939cee054f9b911fe3933b3b
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Siddarth Gajjar
2020-10-12 11:25:22 +00:00
committed by Thibault Delavallée
parent a4975d8a4a
commit 0fa5fe59a2
2 changed files with 7 additions and 2 deletions
@@ -634,7 +634,12 @@ odoo.define('website_slides.fullscreen', function (require) {
return self._renderSlide();
}).then(function() {
if (slide._autoSetDone && !session.is_website_user) { // no useless RPC call
return self._setCompleted(slide.id);
if (['document', 'presentation'].includes(slide.type)) {
// only set the slide as completed after iFrame is loaded to avoid concurrent execution with 'embedUrl' controller
self.el.querySelector('iframe.o_wslides_iframe_viewer').addEventListener('load', () => self._setCompleted(slide.id));
} else {
return self._setCompleted(slide.id);
}
}
});
},
@@ -47,7 +47,7 @@ tour.register('course_member', {
}
}, {
trigger: '.o_wslides_fs_sidebar_header.navigation-success-1',
extra_trigger: '.o_wslides_progress_percentage:contains("20")',
extra_trigger: '.o_wslides_progress_percentage:contains("40")',
run: function () {
// check navigation with arrow keys
var event = jQuery.Event("keydown");