[FIX] survey: Fix traceback when creating a question in mobile
This commit fixes the traceback that happens when we try to create a question from the survey form in mobile mode. The problem was due to the context not being propagated to the "add record" button that appears in mobile mode. Therefore, as we use that context in our widget, it crashes. The solution to this is to just use the normal tree view behaviour instead of our override when we are in a mobile environment. LINKS Taskid: 2071342 Pr: #40694 X-original-commit: b394a67ccd527b4ff88f0b59083fd3b59cf97681
This commit is contained in:
committed by
Thibault Delavallée
parent
ba7afeb5bc
commit
74854ebf2c
@@ -5,6 +5,7 @@ var Context = require('web.Context');
|
||||
var FieldOne2Many = require('web.relational_fields').FieldOne2Many;
|
||||
var FieldRegistry = require('web.field_registry');
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
var config = require('web.config');
|
||||
|
||||
var SectionListRenderer = ListRenderer.extend({
|
||||
init: function (parent, state, params) {
|
||||
@@ -168,12 +169,13 @@ var SectionFieldOne2Many = FieldOne2Many.extend({
|
||||
* @param {*} ev
|
||||
*/
|
||||
_onAddRecord: function (ev) {
|
||||
var context_str = ev.data.context && ev.data.context[0];
|
||||
var context = new Context(context_str).eval();
|
||||
if (context['default_' + this.sectionFieldName]){
|
||||
this.editable = "bottom";
|
||||
} else {
|
||||
this.editable = null;
|
||||
this.editable = null;
|
||||
if (!config.device.isMobile){
|
||||
var context_str = ev.data.context && ev.data.context[0];
|
||||
var context = new Context(context_str).eval();
|
||||
if (context['default_' + this.sectionFieldName]){
|
||||
this.editable = "bottom";
|
||||
}
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Questions">
|
||||
<field name="question_and_page_ids" nolabel="1" widget="question_page_one2many" context="{'default_survey_id': active_id, 'default_questions_selection': questions_selection}">
|
||||
<field name="question_and_page_ids" nolabel="1" widget="question_page_one2many" mode="tree,kanban" context="{'default_survey_id': active_id, 'default_questions_selection': questions_selection}">
|
||||
<tree decoration-bf="is_page" editable="bottom">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="title"/>
|
||||
|
||||
Reference in New Issue
Block a user