diff --git a/addons/website_event/models/event_event.py b/addons/website_event/models/event_event.py index 3fad0c76b56..77b66edee2a 100644 --- a/addons/website_event/models/event_event.py +++ b/addons/website_event/models/event_event.py @@ -208,7 +208,7 @@ class Event(models.Model): When synchronizing questions: - * lines that no answer are removed; + * lines with no registered answers are removed; * type lines are added; """ if self._origin.question_ids: @@ -229,22 +229,12 @@ class Event(models.Model): command = [(3, question.id) for question in questions_toremove] else: command = [(5, 0)] - if event.event_type_id.question_ids: - command += [ - (0, 0, { - 'answer_ids': [(0, 0, { - 'name': answer.name, - 'sequence': answer.sequence - }) for answer in question.answer_ids], - 'is_mandatory_answer': question.is_mandatory_answer, - 'once_per_order': question.once_per_order, - 'question_type': question.question_type, - 'sequence': question.sequence, - 'title': question.title, - }) for question in event.event_type_id.question_ids - ] event.question_ids = command + # copy questions so changes in the event don't affect the event type + for question in event.event_type_id.question_ids: + event.question_ids += question.copy({'event_type_id': False}) + # ------------------------------------------------------------------------- # CONSTRAINT METHODS # ------------------------------------------------------------------------- diff --git a/addons/website_event/tests/test_event_internals.py b/addons/website_event/tests/test_event_internals.py index b460990c5ac..842a88e772d 100644 --- a/addons/website_event/tests/test_event_internals.py +++ b/addons/website_event/tests/test_event_internals.py @@ -14,7 +14,13 @@ class TestEventData(TestEventQuestionCommon): @users('user_eventmanager') def test_event_type_configuration_from_type(self): + """ Enure configuration & translations are copied from Event Type on Event creation """ + self.env['res.lang'].sudo()._activate_lang('nl_NL') + event_type = self.event_type_questions.with_user(self.env.user) + event_type_question_nl = self.event_question_1.with_context(lang='nl_NL') + event_type_question_nl.title = "Vraag1" + event_type_question_nl.answer_ids[0].name = "V1-Antwoord1" event = self.env['event.event'].create({ 'name': 'Event Update Type', @@ -41,6 +47,18 @@ class TestEventData(TestEventQuestionCommon): self.assertEqual( set(event.general_question_ids[0].mapped('answer_ids.name')), set(['Q2-Answer1', 'Q2-Answer2'])) + # verify translations + event_question_nl = event.specific_question_ids.filtered_domain([ + ('title', '=', self.event_question_1.title), + ]).with_context(lang='nl_NL') + self.assertNotEqual(event_question_nl.title, self.event_question_1.title, + "Translated title should differ from untranslated title.") + self.assertEqual(event_question_nl.title, event_type_question_nl.title, + "Translated title should be copied.") + self.assertEqual( + set(event_question_nl.answer_ids.mapped('name')), + set(event_type_question_nl.answer_ids.mapped('name')), + "Translated answer names should be copied.") def test_process_attendees_form(self): event = self.env['event.event'].create({