From e900b3868cd5fb721eed1e1215afa464d50862fe Mon Sep 17 00:00:00 2001 From: "Maruan Aguerdouh (magm)" Date: Thu, 21 Mar 2024 13:31:30 +0100 Subject: [PATCH] [FIX] website_slides: copy courses with visibility set to members Issue: When trying to duplicate courses with the visibility set to members we won't be able to duplicate it, since when creating the duplicate course we won't copy the enroll policy and instead we will apply the default value, 'open' which triggers our validation error. Steps to reproduce: 1. Install website_slides. 2. Create a new eLearning course. 3. Set the options: -Show course to: Course Attendees -Enroll Policy: On Invitation 4. Try to create a copy of this course. Solution: If we allow the copy of the enroll policy we will make sure that the new created course has the right parameters to be created. opw-3749209 closes odoo/odoo#158651 X-original-commit: f17a3d331f877116271e014c5a7b61938311944c Signed-off-by: Maruan Aguerdouh Mohtar (magm) --- addons/website_slides/models/slide_channel.py | 3 +++ addons/website_slides/tests/test_slide_channel.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index efc07789002..3500f4165c1 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -742,6 +742,9 @@ class Channel(models.Model): if 'name' not in default: default['name'] = f"{self.name} ({_('copy')})" + if 'enroll' not in default and self.visibility == "members": + default['enroll'] = 'invite' + return super().copy_data(default) def write(self, vals): diff --git a/addons/website_slides/tests/test_slide_channel.py b/addons/website_slides/tests/test_slide_channel.py index d181188393a..06e057f8b80 100644 --- a/addons/website_slides/tests/test_slide_channel.py +++ b/addons/website_slides/tests/test_slide_channel.py @@ -400,3 +400,6 @@ class TestSequencing(slides_common.SlidesCase): self.assertEqual(channel.visibility, 'members') self.assertEqual(channel.enroll, 'invite') + + copied_channel = channel.copy() + self.assertEqual(copied_channel.enroll, 'invite', "Copied channel should have the same enroll field value")