[FIX] survey: avoid returning empty navigation template

This commit fixes the survey navigation rendering by always returning valid
HTML even when no buttons are displayed.

Indeed, in some cases, such as on the "thank you" page, we don't display any
buttons, meaning that the returned template will be an empty string, which in
turn prevents the re-rendering of this part of the page in the JS part of the
survey form management.

To avoid this issue, we simply add an enclosing div tag into the template so
that the template always returns valid HTML no matter the use case.

Task-2642787

closes odoo/odoo#78250

X-original-commit: 5504f9a1c13cee053f3142ad8eeb98d75311ee78
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
This commit is contained in:
Aurélien Warnon
2021-10-12 15:54:43 +00:00
committed by Thibault Delavallée
parent 9b47e248de
commit 524058919d
@@ -137,14 +137,17 @@
</template>
<template id="survey_navigation" name="Survey: Navigation">
<button t-if="can_go_back"
type="submit" class="btn p-0 shadow-none o_survey_navigation_submit" name="button_submit" value="previous" t-att-data-previous-page-id="previous_page_id">
<i class="border-left fa fa-chevron-left p-2" />
</button>
<button t-if="survey and survey.questions_layout in ['page_per_question', 'page_per_section'] and answer and answer.state != 'done' and not answer.is_session_answer"
type="submit" class="btn p-0 shadow-none o_survey_navigation_submit" t-att-value="'next' if not survey_last else 'finish'">
<i class="border-left fa fa-chevron-right p-2" />
</button>
<!-- Keep this enclosing div so that the template always returns valid HTML content, no matter the use case -->
<div class="d-inline-block">
<button t-if="can_go_back"
type="submit" class="btn p-0 shadow-none o_survey_navigation_submit" name="button_submit" value="previous" t-att-data-previous-page-id="previous_page_id">
<i class="border-left fa fa-chevron-left p-2" />
</button>
<button t-if="survey and survey.questions_layout in ['page_per_question', 'page_per_section'] and answer and answer.state != 'done' and not answer.is_session_answer"
type="submit" class="btn p-0 shadow-none o_survey_navigation_submit" t-att-value="'next' if not survey_last else 'finish'">
<i class="border-left fa fa-chevron-right p-2" />
</button>
</div>
</template>
</data>