diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-26 10:48:42 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-26 15:15:59 +0200 |
| commit | f72bc6c9bed2d22d3e9b980b6c50f1d5a48ce9fd (patch) | |
| tree | 9176d58bcb2529a4b4e2a1568fbe9dfe33dadc3e | |
| parent | 62f446004f07772a56543c30af26f22a553970e9 (diff) | |
[FIX] web: Pivot: don't reload twice on expand all
Before this rev., the option 'reload: false' wasn't correctly
passed when clicking on 'Expand All', and the data was reloaded
twice.
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_controller.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/views/pivot_tests.js | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js index ae1b372e476..3902599e55c 100644 --- a/addons/web/static/src/js/views/pivot/pivot_controller.js +++ b/addons/web/static/src/js/views/pivot/pivot_controller.js @@ -221,7 +221,7 @@ var PivotController = AbstractController.extend({ } if ($target.hasClass('o_pivot_expand_button')) { this.model.expandAll(); - this.update({reload: false}); + this.update({}, {reload: false}); } if ($target.parents('.o_pivot_measures_list').length) { var parent = $target.parent(); diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js index d803cf76f9d..58563c28a8f 100644 --- a/addons/web/static/tests/views/pivot_tests.js +++ b/addons/web/static/tests/views/pivot_tests.js @@ -551,8 +551,9 @@ QUnit.module('Views', { }); QUnit.test('can expand all rows', function (assert) { - assert.expect(4); + assert.expect(7); + var nbReadGroups = 0; var pivot = createView({ View: PivotView, model: "partner", @@ -561,14 +562,23 @@ QUnit.module('Views', { '<field name="foo" type="measure"/>' + '<field name="product_id" type="row"/>' + '</pivot>', + mockRPC: function (route, args) { + if (args.method === 'read_group') { + nbReadGroups++; + } + return this._super.apply(this, arguments); + }, }); + assert.strictEqual(nbReadGroups, 2, "should have done 2 read_group RPCS"); assert.strictEqual(pivot.$('td.o_pivot_cell_value').text(), "321220", "should have proper values in cells (total, result 1, result 2)"); // expand on date:days, product + nbReadGroups = 0; pivot.update({groupBy: ['date:days', 'product_id']}); + assert.strictEqual(nbReadGroups, 3, "should have done 3 read_group RPCS"); assert.strictEqual(pivot.$('tbody tr').length, 8, "should have 7 rows (total + 3 for December and 2 for October and April)"); @@ -580,8 +590,10 @@ QUnit.module('Views', { "should have 6 rows now"); // expand all + nbReadGroups = 0; $('.o_pivot_expand_button').click(); + assert.strictEqual(nbReadGroups, 3, "should have done 3 read_group RPCS"); assert.strictEqual(pivot.$('tbody tr').length, 8, "should have 8 rows again"); |
