[FIX] web: update buttons in editable list view when no changes

When I introduced this line in 374295b, I was working on the form
view and didn't realize I would be breaking the editable list view.

The _setMode function only updates the buttons when given the id of
a record. Since I was working on a form view at the time, I didn't
need to give a recordID to make it work since the default ID of a
form view is the id of the record itself. However, in editable list
view, the id of the view is a list of ids, so the buttons would not
be updated in this case.
This commit is contained in:
David Monjoie
2017-06-23 09:58:45 +02:00
parent 3cbfc40303
commit 0236ac510b
2 changed files with 11 additions and 2 deletions
@@ -423,7 +423,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
});
if (!options.stayInEdit) {
saveDef = saveDef.then(function (fieldNames) {
var def = fieldNames.length ? self._confirmSave(recordID) : self._setMode('readonly');
var def = fieldNames.length ? self._confirmSave(recordID) : self._setMode('readonly', recordID);
return def.then(function () {
return fieldNames;
});
+10 -1
View File
@@ -136,7 +136,7 @@ QUnit.module('Views', {
});
QUnit.test('simple editable rendering', function (assert) {
assert.expect(9);
assert.expect(12);
var list = createView({
View: ListView,
@@ -164,6 +164,15 @@ QUnit.module('Views', {
"should have a visible save button");
assert.ok(list.$buttons.find('.o_list_button_discard').is(':visible'),
"should have a visible discard button");
list.$buttons.find('.o_list_button_save').click();
assert.ok(list.$buttons.find('.o_list_button_add').is(':visible'),
"should have a visible Create button");
assert.ok(!list.$buttons.find('.o_list_button_save').is(':visible'),
"should not have a visible save button");
assert.ok(!list.$buttons.find('.o_list_button_discard').is(':visible'),
"should not have a visible discard button");
list.destroy();
});