From 74854ebf2ca1e6b716f72ddd72674dd50abc0c76 Mon Sep 17 00:00:00 2001 From: qmo-odoo Date: Fri, 22 Nov 2019 11:13:14 +0000 Subject: [PATCH] [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 --- .../static/src/js/fields_section_one2many.js | 14 ++++++++------ addons/survey/views/survey_survey_views.xml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/survey/static/src/js/fields_section_one2many.js b/addons/survey/static/src/js/fields_section_one2many.js index 72fa2e11f15..7f82200fb90 100644 --- a/addons/survey/static/src/js/fields_section_one2many.js +++ b/addons/survey/static/src/js/fields_section_one2many.js @@ -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); }, diff --git a/addons/survey/views/survey_survey_views.xml b/addons/survey/views/survey_survey_views.xml index e728e29a84f..56d20ca768b 100644 --- a/addons/survey/views/survey_survey_views.xml +++ b/addons/survey/views/survey_survey_views.xml @@ -54,7 +54,7 @@ - +