Commit 9ba19439 authored by Jordan - Le Filament's avatar Jordan - Le Filament

[fix] conditonnal questions when copy survey

parent 48fb5b0a
......@@ -21,3 +21,26 @@ class SurveyQuestionConditional(models.Model):
def _onchange_constr_mandatory(self):
if self.constr_mandatory:
self.conditional = False
class Survey(models.Model):
_inherit = 'survey.survey'
def copy(self, default=None):
res = super(Survey, self).copy(default)
for page in res.page_ids:
for question in page.question_ids:
if question.conditional:
new_conditional_question_id = question.search([
['page_id', '=', question.page_id.id],
['question', '=', question.conditional_question_id.question]
])
new_conditional_option_id = res.env['survey.label'].search([
['question_id', '=', new_conditional_question_id.id],
['value', '=', question.conditional_option_id.value]
])
question.write({
'conditional_question_id': new_conditional_question_id.id,
'conditional_option_id': new_conditional_option_id.id
})
return res
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment