From 66f7d393d3d6b0ac77cfde9172be86f77d9b63b1 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Wed, 11 Oct 2017 10:40:46 +0200 Subject: [PATCH] [FIX] web: debug mode tooltip Display properly the content of context object instead of [object Object]. --- .../static/src/js/views/form/form_renderer.js | 2 +- addons/web/static/src/xml/base_common.xml | 4 +-- addons/web/static/tests/views/form_tests.js | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index ab491adc9b1..e5a0646dd5c 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -812,7 +812,7 @@ var FormRenderer = BasicRenderer.extend({ _.each(this.allFieldWidgets[this.state.id], function (widget) { var idForLabel = self.idsForLabels[widget.name]; var $label = idForLabel ? self.$('label[for=' + idForLabel + ']') : $(); - if (core.debug || widget.attrs.help || widget.field.help) { + if (config.debug || widget.attrs.help || widget.field.help) { self._addFieldTooltip(widget, $label); } if (widget.attrs.widget === 'upgrade_boolean') { diff --git a/addons/web/static/src/xml/base_common.xml b/addons/web/static/src/xml/base_common.xml index 3e0d6291dfd..252858b01f3 100644 --- a/addons/web/static/src/xml/base_common.xml +++ b/addons/web/static/src/xml/base_common.xml @@ -59,11 +59,11 @@
  • Context: - +
  • Domain: - +
  • Modifiers: diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 2b4c70a9399..f3f64b1b002 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -5920,5 +5920,36 @@ QUnit.module('Views', { form.destroy(); }); + + QUnit.test('proper context stringification in debug mode tooltip', function (assert) { + assert.expect(2); + + var initialDebugMode = config.debug; + config.debug = true; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
    ' + + '' + + '' + + '' + + '
    ', + }); + + var $field = form.$('[name="product_id"]'); + $field.tooltip('show', true); + $field.trigger($.Event('mouseenter')); + assert.strictEqual($('.oe_tooltip_technical>li[data-item="context"]').length, + 1, 'context should be present for this field'); + assert.strictEqual($('.oe_tooltip_technical>li[data-item="context"]')[0].lastChild.wholeText.trim(), + "{'lang': 'en_US'}", "context should be properly stringified"); + + config.debug = initialDebugMode; + form.destroy(); + }); + + }); });