[FIX] survey: avoid crash for misconfigured questions
Currently, if the user configures his survey with questions of type 'simple_choice', 'multiple_choice' and 'matrix', but doesn't configure any selectable choices, the survey result page can crash. This is not really a "standard" use case but this commit adds a few checks to avoid a complete traceback and instead give empty data results. Task-2622869 closes odoo/odoo#75586 closes odoo/odoo#76606 X-original-commit: 8051be7c96417cf2feb9d542bb3d230022c8cc54 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:
@@ -94,25 +94,27 @@ publicWidget.registry.SurveyResultChart = publicWidget.Widget.extend({
|
||||
return this._super.apply(this, arguments).then(function () {
|
||||
self.graphData = self.$el.data("graphData");
|
||||
|
||||
switch (self.$el.data("graphType")) {
|
||||
case 'multi_bar':
|
||||
self.chartConfig = self._getMultibarChartConfig();
|
||||
break;
|
||||
case 'bar':
|
||||
self.chartConfig = self._getBarChartConfig();
|
||||
break;
|
||||
case 'pie':
|
||||
self.chartConfig = self._getPieChartConfig();
|
||||
break;
|
||||
case 'doughnut':
|
||||
self.chartConfig = self._getDoughnutChartConfig();
|
||||
break;
|
||||
case 'by_section':
|
||||
self.chartConfig = self._getSectionResultsChartConfig();
|
||||
break;
|
||||
}
|
||||
if (self.graphData && self.graphData.length !== 0) {
|
||||
switch (self.$el.data("graphType")) {
|
||||
case 'multi_bar':
|
||||
self.chartConfig = self._getMultibarChartConfig();
|
||||
break;
|
||||
case 'bar':
|
||||
self.chartConfig = self._getBarChartConfig();
|
||||
break;
|
||||
case 'pie':
|
||||
self.chartConfig = self._getPieChartConfig();
|
||||
break;
|
||||
case 'doughnut':
|
||||
self.chartConfig = self._getDoughnutChartConfig();
|
||||
break;
|
||||
case 'by_section':
|
||||
self.chartConfig = self._getSectionResultsChartConfig();
|
||||
break;
|
||||
}
|
||||
|
||||
self._loadChart();
|
||||
self._loadChart();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" t-att-id="'survey_data_question_%d' % question.id">
|
||||
<table class="table table-hover table-sm text-right">
|
||||
<thead>
|
||||
<thead t-if="table_data">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th class="text-right" t-foreach="table_data[0]['columns']" t-as="column_data">
|
||||
|
||||
Reference in New Issue
Block a user