diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-02-21 15:37:19 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-02-21 15:37:19 +0100 |
| commit | 1d2b6f1bef6af13245d29d56cbb5f9d61f9ca038 (patch) | |
| tree | 8ea1d203aef83d287de9ec578f81bd64eedb7359 /addons/web/static | |
| parent | f945b1bcc21621cfc056e40f4d66b7181d19239e (diff) | |
| parent | 84143a34b313c01b0b37b7d7246ce3d5c9476002 (diff) | |
[MERGE] forward port branch 12.0 up to 84143a34b31
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/lib/moment/locale/es.js | 20 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/abstract_storage_service.js | 11 | ||||
| -rw-r--r-- | addons/web/static/src/js/core/utils.js | 12 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 1 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/control_panel/search/search_filters.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_renderer.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_model.js | 8 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_renderer.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/scss/form_view.scss | 4 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/chrome/user_menu_tests.js | 1 | ||||
| -rw-r--r-- | addons/web/static/tests/core/util_tests.js | 22 | ||||
| -rw-r--r-- | addons/web/static/tests/core/widget_tests.js | 24 | ||||
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_mock.js | 5 | ||||
| -rw-r--r-- | addons/web/static/tests/views/abstract_controller_tests.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/views/pivot_tests.js | 108 |
16 files changed, 212 insertions, 17 deletions
diff --git a/addons/web/static/lib/moment/locale/es.js b/addons/web/static/lib/moment/locale/es.js index eb9e0809dfe..6d1f5907968 100644 --- a/addons/web/static/lib/moment/locale/es.js +++ b/addons/web/static/lib/moment/locale/es.js @@ -8,21 +8,30 @@ typeof define === 'function' && define.amd ? define(['../moment'], factory) : factory(global.moment) }(this, (function (moment) { 'use strict'; +var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'), + monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); - -var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'); -var monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); +var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; +var monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; var es = moment.defineLocale('es', { months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), monthsShort : function (m, format) { - if (/-MMM-/.test(format)) { + if (!m) { + return monthsShortDot; + } else if (/-MMM-/.test(format)) { return monthsShort[m.month()]; } else { return monthsShortDot[m.month()]; } }, - monthsParseExact : true, + monthsRegex : monthsRegex, + monthsShortRegex : monthsRegex, + monthsStrictRegex : /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i, + monthsShortStrictRegex : /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i, + monthsParse : monthsParse, + longMonthsParse : monthsParse, + shortMonthsParse : monthsParse, weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'), weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'), weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'), @@ -57,6 +66,7 @@ var es = moment.defineLocale('es', { future : 'en %s', past : 'hace %s', s : 'unos segundos', + ss : '%d segundos', m : 'un minuto', mm : '%d minutos', h : 'una hora', diff --git a/addons/web/static/src/js/core/abstract_storage_service.js b/addons/web/static/src/js/core/abstract_storage_service.js index 34dd24b2be6..ef828b5dd5c 100644 --- a/addons/web/static/src/js/core/abstract_storage_service.js +++ b/addons/web/static/src/js/core/abstract_storage_service.js @@ -13,6 +13,17 @@ var AbstractStorageService = AbstractService.extend({ // this abstraction storage: null, + /** + * @override + */ + destroy: function () { + // storage can be permanent or transient, destroy transient ones + if ((this.storage || {}).destroy) { + this.storage.destroy(); + } + this._super.apply(this, arguments); + }, + //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js index 5d707d951bb..19916e79a4c 100644 --- a/addons/web/static/src/js/core/utils.js +++ b/addons/web/static/src/js/core/utils.js @@ -112,7 +112,17 @@ var utils = { var d2 = Math.pow(10, decimals); var val = _t('kMGTPE'); var symbol = ''; - for (var i = val.length - 1 ; i > 0 ; i--) { + var numberMagnitude = number.toExponential().split('e')[1]; + // the case numberMagnitude >= 21 corresponds to a number + // better expressed in the scientific format. + if (numberMagnitude >= 21) { + // we do not use number.toExponential(decimals) because we want to + // avoid the possible useless O decimals: 1e.+24 prefered to 1.0e+24 + number = Math.round(number * Math.pow(10, decimals - numberMagnitude)) / d2; + // formatterCallback seems useless here. + return number + 'e' + numberMagnitude; + } + for (var i = val.length; i > 0 ; i--) { var s = Math.pow(10, i * 3); if (s <= number / Math.pow(10, minDigits - 1)) { number = Math.round(number * d2 / s) / d2; diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 4d266db409d..dc75ba8ea2a 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -2911,6 +2911,7 @@ var AceEditor = DebouncedField.extend({ if (this.aceEditor) { this.aceEditor.destroy(); } + this._super.apply(this, arguments); }, //-------------------------------------------------------------------------- diff --git a/addons/web/static/src/js/views/control_panel/search/search_filters.js b/addons/web/static/src/js/views/control_panel/search/search_filters.js index 57aa34a84a7..80a9019c02d 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_filters.js +++ b/addons/web/static/src/js/views/control_panel/search/search_filters.js @@ -242,7 +242,7 @@ var DateTime = Field.extend({ _create_new_widget: function (name) { this[name] = new (this._get_widget_class())(this); return this[name].appendTo(this.$el).then((function () { - this[name].setValue(moment(new Date())); + this[name].setValue(moment()); }).bind(this)); }, _get_widget_class: function () { diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js index 09706695bbc..8cff755676c 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -456,6 +456,10 @@ return AbstractRenderer.extend({ // of the tiny margins. if (ticksLabels.length > 3) { $svgContainer.find('svg .nv-x g.nv-axisMaxMin-x > text').hide(); + } else { + // Since the graph is on full container have first and last label in the container + $svgContainer.find('svg .nv-x g.nv-axisMin-x > text').css({'text-anchor': 'start'}); + $svgContainer.find('svg .nv-x g.nv-axisMax-x > text').css({'text-anchor': 'end'}); } return chart; diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js index 4c37b823639..3f195c1ea24 100644 --- a/addons/web/static/src/js/views/pivot/pivot_model.js +++ b/addons/web/static/src/js/views/pivot/pivot_model.js @@ -237,7 +237,7 @@ var PivotModel = AbstractModel.extend({ [ this.data.timeRangeDescription.toString(), this.data.comparisonTimeRangeDescription.toString(), - 'Variation' + _t('Variation') ], makeMeasure ) @@ -443,8 +443,10 @@ var PivotModel = AbstractModel.extend({ self._updateMainGroupBys(old_row, self.data.main_row); } - self._updateTree(old_col.root, self.data.main_col.root); - self._updateMainGroupBys(old_col, self.data.main_col); + if (!('pivot_column_groupby' in (params.context || {}))) { + self._updateTree(old_col.root, self.data.main_col.root); + self._updateMainGroupBys(old_col, self.data.main_col); + } }); }, /** diff --git a/addons/web/static/src/js/views/pivot/pivot_renderer.js b/addons/web/static/src/js/views/pivot/pivot_renderer.js index 787e28e38a9..8352759c695 100644 --- a/addons/web/static/src/js/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/js/views/pivot/pivot_renderer.js @@ -6,6 +6,7 @@ var core = require('web.core'); var field_utils = require('web.field_utils'); var QWeb = core.qweb; +var _t = core._t; var PivotRenderer = AbstractRenderer.extend({ tagName: 'table', @@ -171,7 +172,7 @@ var PivotRenderer = AbstractRenderer.extend({ $thead.append($row); } if (this.compare) { - var colLabels = [this.timeRangeDescription, this.comparisonTimeRangeDescription, 'Variation']; + var colLabels = [this.timeRangeDescription, this.comparisonTimeRangeDescription, _t('Variation')]; var dataTypes = ['data', 'comparisonData', 'variation']; $row = $('<tr>'); for (i = 0; i < 3 * nbrCols; i++) { diff --git a/addons/web/static/src/scss/form_view.scss b/addons/web/static/src/scss/form_view.scss index 5642e656dea..0645e00544e 100644 --- a/addons/web/static/src/scss/form_view.scss +++ b/addons/web/static/src/scss/form_view.scss @@ -744,6 +744,10 @@ .o_field_widget { width: 50%; flex: 0 0 auto; + + &.o_field_many2manytags > .o_field_widget { + flex: 1 0 50px; + } } button.btn-link:first-child { padding-left: 0; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 5e2f27ccc66..e11184ebb1e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -348,7 +348,7 @@ <t t-raw="item.label"/> </a> </t> - <div class="dropdown-menu" role="menu"> + <div class="dropdown-menu o_dropdown_menu" role="menu"> <t t-foreach="widget.items[section.name]" t-as="item"> <t t-if="section.name == 'files'"> <t t-set="item.title"> diff --git a/addons/web/static/tests/chrome/user_menu_tests.js b/addons/web/static/tests/chrome/user_menu_tests.js index 600ac125dd4..0151afdf6d6 100644 --- a/addons/web/static/tests/chrome/user_menu_tests.js +++ b/addons/web/static/tests/chrome/user_menu_tests.js @@ -25,6 +25,7 @@ QUnit.module('chrome', {}, function () { "should have a 'Shortcuts' item"); userMenu.destroy(); + parent.destroy(); }); }); diff --git a/addons/web/static/tests/core/util_tests.js b/addons/web/static/tests/core/util_tests.js index c7158083dcb..f81dea7ce4e 100644 --- a/addons/web/static/tests/core/util_tests.js +++ b/addons/web/static/tests/core/util_tests.js @@ -55,6 +55,26 @@ QUnit.module('core', {}, function () { assert.strictEqual(is_bin_size('64.2 Кб'), true); }); + QUnit.test('human_number', function (assert) { + assert.expect(13); + + var human_number = utils.human_number; + + assert.strictEqual(human_number(1020, 2, 1), '1.02k'); + assert.strictEqual(human_number(1020000, 2, 2), '1020k'); + assert.strictEqual(human_number(10200000, 2, 2), '10.2M'); + assert.strictEqual(human_number(1020, 2, 1), '1.02k'); + assert.strictEqual(human_number(1002, 2, 1), '1k'); + assert.strictEqual(human_number(101, 2, 1), '101'); + assert.strictEqual(human_number(64.2, 2, 1), '64'); + assert.strictEqual(human_number(1e+18), '1E'); + assert.strictEqual(human_number(1e+21, 2, 1), '1e+21'); + assert.strictEqual(human_number(1.0045e+22, 2, 1), '1e+22'); + assert.strictEqual(human_number(1.0045e+22, 3, 1), '1.005e+22'); + assert.strictEqual(human_number(1.012e+43, 2, 1), '1.01e+43'); + assert.strictEqual(human_number(1.012e+43, 2, 2), '1.01e+43'); + }); + }); -});
\ No newline at end of file +}); diff --git a/addons/web/static/tests/core/widget_tests.js b/addons/web/static/tests/core/widget_tests.js index 834033a1769..0eb4192c4a1 100644 --- a/addons/web/static/tests/core/widget_tests.js +++ b/addons/web/static/tests/core/widget_tests.js @@ -24,6 +24,7 @@ QUnit.module('core', {}, function () { var fn = w.proxy('exec'); fn(); assert.ok(w.executed, 'should execute the named method in the right context'); + w.destroy(); }); QUnit.test('proxy (String)(*args)', function (assert) { @@ -39,6 +40,7 @@ QUnit.module('core', {}, function () { fn(42); assert.ok(w.executed, "should execute the named method in the right context"); assert.strictEqual(w.executed, 42, "should be passed the proxy's arguments"); + w.destroy(); }); QUnit.test('proxy (String), include', function (assert) { @@ -59,6 +61,7 @@ QUnit.module('core', {}, function () { fn(); assert.strictEqual(w.executed, 2, "should be lazily resolved"); + w.destroy(); }); QUnit.test('proxy (Function)', function (assert) { @@ -69,6 +72,7 @@ QUnit.module('core', {}, function () { var fn = w.proxy(function () { this.executed = true; }); fn(); assert.ok(w.executed, "should set the function's context (like Function#bind)"); + w.destroy(); }); QUnit.test('proxy (Function)(*args)', function (assert) { @@ -79,6 +83,7 @@ QUnit.module('core', {}, function () { var fn = w.proxy(function (arg) { this.executed = arg; }); fn(42); assert.strictEqual(w.executed, 42, "should be passed the proxy's arguments"); + w.destroy(); }); @@ -99,6 +104,7 @@ QUnit.module('core', {}, function () { assert.strictEqual(widget.el.nodeName, 'DIV', "should have generated the default element"); assert.strictEqual(widget.el.attributes.length, 0, "should not have generated any attribute"); assert.ok(_.isEmpty(widget.$el.html(), "should not have generated any content")); + widget.destroy(); }); QUnit.test('no template, custom tag', function (assert) { @@ -111,6 +117,7 @@ QUnit.module('core', {}, function () { widget.renderElement(); assert.strictEqual(widget.el.nodeName, 'UL', "should have generated the custom element tag"); + widget.destroy(); }); QUnit.test('no template, @id', function (assert) { @@ -124,6 +131,7 @@ QUnit.module('core', {}, function () { assert.strictEqual(widget.el.attributes.length, 1, "should have one attribute"); assert.hasAttrValue(widget.$el, 'id', 'foo', "should have generated the id attribute"); assert.strictEqual(widget.el.id, 'foo', "should also be available via property"); + widget.destroy(); }); QUnit.test('no template, @className', function (assert) { @@ -136,6 +144,7 @@ QUnit.module('core', {}, function () { assert.strictEqual(widget.el.className, 'oe_some_class', "should have the right property"); assert.hasAttrValue(widget.$el, 'class', 'oe_some_class', "should have the right attribute"); + widget.destroy(); }); QUnit.test('no template, bunch of attributes', function (assert) { @@ -166,6 +175,7 @@ QUnit.module('core', {}, function () { assert.hasAttrValue(widget.$el, 'clark', 'gable'); assert.hasAttrValue(widget.$el, 'spoiler', 'snape kills dumbledore'); + widget.destroy(); }); QUnit.test('template', function (assert) { @@ -193,6 +203,7 @@ QUnit.module('core', {}, function () { assert.strictEqual(widget.el.nodeName, 'OL'); assert.strictEqual(widget.$el.children().length, 5); assert.strictEqual(widget.el.textContent, '01234'); + widget.destroy(); }); QUnit.test('repeated', function (assert) { @@ -219,6 +230,8 @@ QUnit.module('core', {}, function () { widget.renderElement(); assert.strictEqual($fix.find('p').text(), '36', "DOM fixture should use new value"); assert.strictEqual(widget.$el.text(), '36', "should set new value"); + }).always(function () { + widget.destroy(); }); }); @@ -257,6 +270,7 @@ QUnit.module('core', {}, function () { assert.ok(widget.$('li:eq(3)').is(widget.$el.find('li:eq(3)')), "should do the same thing as calling find on the widget root"); + widget.destroy(); }); @@ -285,6 +299,7 @@ QUnit.module('core', {}, function () { for(var i=0; i<3; ++i) { assert.ok(a[i], "should pass test " + i); } + widget.destroy(); }); QUnit.test('undelegate', function (assert) { @@ -310,6 +325,7 @@ QUnit.module('core', {}, function () { widget.$('li').click(); assert.ok(!clicked, "undelegate should unbind events delegated"); assert.ok(newclicked, "undelegate should only unbind events it created"); + widget.destroy(); }); QUnit.module('Widget, and async stuff'); @@ -321,7 +337,8 @@ QUnit.module('core', {}, function () { return concurrency.asyncWhen(widget.start()) .then(function () { return widget.alive(concurrency.asyncWhen()); }) - .then(function () { assert.ok(true); }); + .then(function () { assert.ok(true); }) + .always(function () { widget.destroy(); }); }); QUnit.test("alive(dead)", function (assert) { @@ -355,7 +372,8 @@ QUnit.module('core', {}, function () { var widget = new (Widget.extend({})); return concurrency.asyncWhen(widget.start()) .then(function () { return widget.alive(concurrency.asyncWhen(), true) }) - .then(function () { assert.ok(true); }); + .then(function () { assert.ok(true); }) + .always(function () { widget.destroy(); }); }); QUnit.test("alive(dead, true)", function (assert) { @@ -445,4 +463,4 @@ QUnit.module('core', {}, function () { }); -});
\ No newline at end of file +}); diff --git a/addons/web/static/tests/helpers/test_utils_mock.js b/addons/web/static/tests/helpers/test_utils_mock.js index 3eaaae0a46f..ad7878001f3 100644 --- a/addons/web/static/tests/helpers/test_utils_mock.js +++ b/addons/web/static/tests/helpers/test_utils_mock.js @@ -198,6 +198,11 @@ function addMockEnvironment(widget, params) { // widget is destroyed, at the end of each test to avoid collisions core.bus.trigger('clear_cache'); + _(services).chain() + .compact() // services can be defined but null (e.g. ajax) + .reject(function (s) { return s.isDestroyed(); }) + .invoke('destroy'); + DebouncedField.prototype.DEBOUNCE = initialDebounceValue; dom.DEBOUNCE = initialDOMDebounceValue; if (params.debounce === false) { diff --git a/addons/web/static/tests/views/abstract_controller_tests.js b/addons/web/static/tests/views/abstract_controller_tests.js index cf5810219c7..66827540fc2 100644 --- a/addons/web/static/tests/views/abstract_controller_tests.js +++ b/addons/web/static/tests/views/abstract_controller_tests.js @@ -67,6 +67,8 @@ odoo.define("base.abstract_controller_tests", function(require) { testUtils.dom.click(view.$(".simple")); testUtils.dom.click(view.$(".with-child span")); assert.verifySteps(["a1", "a2"]); + + view.destroy(); } ); } diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js index 7af2892ac33..9abaac5ad1e 100644 --- a/addons/web/static/tests/views/pivot_tests.js +++ b/addons/web/static/tests/views/pivot_tests.js @@ -1007,6 +1007,95 @@ QUnit.module('Views', { pivot.destroy(); }); + QUnit.test('Unload Filter, reset display, load another filter', function (assert) { + assert.expect(18); + + var pivot = createView({ + View: PivotView, + model: "partner", + data: this.data, + arch: '<pivot>' + + '<field name="foo" type="measure"/>' + + '</pivot>', + viewOptions: { + context: { + pivot_measures: ['foo'], + pivot_column_groupby: ['customer'], + pivot_row_groupby: ['product_id'], + }, + }, + }); + + // Check Columns + assert.strictEqual(pivot.$('thead .o_pivot_header_cell_opened').length, 1, + 'The column should be grouped'); + assert.strictEqual(pivot.$('thead tr:contains("First")').length, 1, + 'There should be a column "First"'); + assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 1, + 'There should be a column "Second"'); + + // Check Rows + assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_opened').length, 1, + 'The row should be grouped'); + assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 1, + 'There should be a row "xphone"'); + assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 1, + 'There should be a row "xpad"'); + + // Equivalent to unload the filter + var reloadParams = { + context: {}, + }; + pivot.reload(reloadParams); + // collapse all headers + pivot.$('.o_pivot_header_cell_opened').click(); + pivot.$('.o_pivot_header_cell_opened').click(); + + // Check Columns + assert.strictEqual(pivot.$('thead .o_pivot_header_cell_closed').length, 1, + 'The column should not be grouped'); + assert.strictEqual(pivot.$('thead tr:contains("First")').length, 0, + 'There should not be a column "First"'); + assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 0, + 'There should not be a column "Second"'); + + // Check Rows + assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_closed').length, 1, + 'The row should not be grouped'); + assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 0, + 'There should not be a row "xphone"'); + assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 0, + 'There should not be a row "xpad"'); + + // Equivalent to load another filter + reloadParams = { + context: { + pivot_measures: ['foo'], + pivot_column_groupby: ['customer'], + pivot_row_groupby: ['product_id'], + }, + }; + pivot.reload(reloadParams); + + // Check Columns + assert.strictEqual(pivot.$('thead .o_pivot_header_cell_opened').length, 1, + 'The column should be grouped'); + assert.strictEqual(pivot.$('thead tr:contains("First")').length, 1, + 'There should be a column "First"'); + assert.strictEqual(pivot.$('thead tr:contains("Second")').length, 1, + 'There should be a column "Second"'); + + // Check Rows + assert.strictEqual(pivot.$('tbody .o_pivot_header_cell_opened').length, 1, + 'The row should be grouped'); + assert.strictEqual(pivot.$('tbody tr:contains("xphone")').length, 1, + 'There should be a row "xphone"'); + assert.strictEqual(pivot.$('tbody tr:contains("xpad")').length, 1, + 'There should be a row "xpad"'); + + pivot.destroy(); + }); + QUnit.test('correctly uses pivot_ keys from the context', function (assert) { assert.expect(7); @@ -1405,7 +1494,7 @@ QUnit.module('Views', { }); QUnit.test('rendering of pivot view with comparison', function (assert) { - assert.expect(91); + assert.expect(92); this.data.partner.records[0].date = '2016-12-15'; this.data.partner.records[1].date = '2016-12-17'; @@ -1442,6 +1531,17 @@ QUnit.module('Views', { '</pivot>', 'partner,false,search': '<search></search>', }, + intercepts: { + create_filter: function (ev) { + var data = ev.data; + assert.deepEqual(data.filter.context.timeRangeMenuData, { + timeRange: ["&",["date",">=","2016-12-01"],["date","<","2017-01-01"]], + timeRangeDescription: 'This Month', + comparisonTimeRange: ["&",["date",">=","2016-11-01"],["date","<","2016-12-01"]], + comparisonTimeRangeDescription: 'Previous Period', + }); + } + } }); actionManager.doAction({ @@ -1512,6 +1612,12 @@ QUnit.module('Views', { ]; checkCellValues(results); + $('.o_search_options button:contains("Favorites")').click(); + var $favorites = $('.dropdown-menu.o_favorites_menu'); + $favorites.find('a.o_save_search').click(); + $favorites.find('.o_input').val('Fav').trigger('input'); + $favorites.find('button').click(); + unpatchDate(); actionManager.destroy(); }); |
