[FIX] web: create in editable grouped list views

Before this commit, an issue occured when you tried to
create a new record in a editable grouped list view.
A new line was created with an undefined group.

Editable grouped list views are not supported.
So now, we have to switch on the form view when
you click on create. This behavior is already implemented
when you open an existing record.
This commit is contained in:
Adrien Dieudonne
2017-11-09 11:45:04 +01:00
parent a25358eae3
commit fe4f63d325
2 changed files with 13 additions and 6 deletions
@@ -355,8 +355,8 @@ var ListController = BasicController.extend({
// trigger a click on the main bus, which would be then caught by the
// list editable renderer and would unselect the newly created row
event.stopPropagation();
if (this.editable) {
var state = this.model.get(this.handle, {raw: true});
if (this.editable && !state.groupedBy.length) {
this._addRecord();
} else {
this.trigger_up('switch_view', {view_type: 'form', res_id: undefined});
+11 -4
View File
@@ -2624,7 +2624,7 @@ QUnit.module('Views', {
// Editable grouped list views are not supported, so the purpose of this
// test is to check that when a list view is grouped, its editable
// attribute is ignored
assert.expect(4);
assert.expect(5);
var list = createView({
View: ListView,
@@ -2632,8 +2632,9 @@ QUnit.module('Views', {
data: this.data,
arch: '<tree editable="top"><field name="foo"/><field name="bar"/></tree>',
intercepts: {
switch_view: function () {
assert.step('switch view');
switch_view: function (event) {
var resID = event.data.res_id || false;
assert.step('switch view ' + event.data.view_type + ' ' + resID);
},
},
});
@@ -2645,9 +2646,15 @@ QUnit.module('Views', {
// reload with groupBy
list.reload({groupBy: ['bar']});
// clicking on record should open the form view
list.$('.o_group_header:first').click();
list.$('.o_data_cell:first').click();
assert.verifySteps(['switch view'], 'one switch view should have been requested');
// clicking on create button should open the form view
list.$buttons.find('.o_list_button_add').click();
assert.verifySteps(['switch view form 1', 'switch view form false'],
'two switch view to form should have been requested');
list.destroy();
});