diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js
index 6e69c0217b2..2976ab7926a 100644
--- a/addons/web/static/src/js/views/list/list_renderer.js
+++ b/addons/web/static/src/js/views/list/list_renderer.js
@@ -387,15 +387,15 @@ var ListRenderer = BasicRenderer.extend({
var $th = $('
')
.addClass('o_group_name')
.text(name + ' (' + group.count + ')');
- if (group.count > 0) {
- var $arrow = $('')
+ var $arrow = $('')
.css('padding-left', (groupLevel * 20) + 'px')
.css('padding-right', '5px')
- .addClass('fa')
- .toggleClass('fa-caret-right', !group.isOpen)
- .toggleClass('fa-caret-down', group.isOpen);
- $th.prepend($arrow);
+ .addClass('fa');
+ if (group.count > 0) {
+ $arrow.toggleClass('fa-caret-right', !group.isOpen)
+ .toggleClass('fa-caret-down', group.isOpen);
}
+ $th.prepend($arrow);
if (group.isOpen && !group.groupedBy.length && (group.count > group.data.length)) {
var $pager = this._renderGroupPager(group);
var $lastCell = $cells[$cells.length-1];
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 083aa349516..4b33af9f0a6 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -2529,6 +2529,55 @@ QUnit.module('Views', {
list.destroy();
});
+
+ QUnit.test('grouped list view, indentation for empty group', function (assert) {
+ assert.expect(3);
+
+ this.data.foo.fields.priority = {
+ string: "Priority",
+ type: "selection",
+ selection: [[1, "Low"], [2, "Medium"], [3, "High"]],
+ default: 1,
+ };
+ this.data.foo.records.push({id: 5, foo: "blip", int_field: -7, m2o: 1, priority: 2});
+ this.data.foo.records.push({id: 6, foo: "blip", int_field: 5, m2o: 1, priority: 3});
+
+ var list = createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: '',
+ groupBy: ['priority', 'm2o'],
+ mockRPC: function (route, args) {
+ // Override of the read_group to display the row even if there is no record in it,
+ // to mock the behavihour of some fields e.g stage_id on the sale order.
+ if (args.method === 'read_group' && args.kwargs.groupby[0] === "m2o") {
+ return $.when([
+ {
+ id: 8,
+ m2o:[1,"Value 1"],
+ m2o_count: 0
+ }, {
+ id: 2,
+ m2o:[2,"Value 2"],
+ m2o_count: 1
+ }
+ ]);
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ // open the first group
+ list.$('.o_group_header:first').click();
+ assert.strictEqual(list.$('th.o_group_name').eq(1).children().length, 1,
+ "There should be an empty element creating the indentation for the subgroup.");
+ assert.strictEqual(list.$('th.o_group_name').eq(1).children().eq(0).hasClass('fa'), true,
+ "The first element of the row name should have the fa class");
+ assert.strictEqual(list.$('th.o_group_name').eq(1).children().eq(0).is('span'), true,
+ "The first element of the row name should be a span");
+ list.destroy();
+ });
});
});
|