diff options
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 7 | ||||
| -rw-r--r-- | addons/web/static/src/scss/list_view.scss | 1 | ||||
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 52 |
3 files changed, 56 insertions, 4 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 6cb91d152d0..cf3c08128ce 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1990,9 +1990,7 @@ var BasicModel = AbstractModel.extend({ var records = []; var ids = []; list = this._applyX2ManyOperations(list); - if (_.isEmpty(list.data)) { - return $.when(); - } + _.each(list.data, function (localId) { var record = self.localData[localId]; var data = record._changes || record.data; @@ -2003,6 +2001,9 @@ var BasicModel = AbstractModel.extend({ ids.push(many2oneRecord.res_id); model = many2oneRecord.model; }); + if (!ids.length) { + return $.when(); + } return this._rpc({ model: model, method: 'name_get', diff --git a/addons/web/static/src/scss/list_view.scss b/addons/web/static/src/scss/list_view.scss index 49cba9409cc..539b5685a31 100644 --- a/addons/web/static/src/scss/list_view.scss +++ b/addons/web/static/src/scss/list_view.scss @@ -83,7 +83,6 @@ padding: 0px; background-style: none; border-style: none; - height: 0px; display: table-cell; } diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 913ca896b7c..b9aa2d30253 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -2551,6 +2551,58 @@ QUnit.module('relational_fields', { QUnit.module('FieldOne2Many'); + QUnit.test('New record with a o2m also with 2 new records, ordered, and resequenced', function (assert) { + assert.expect(3); + + // Needed to have two new records in a single stroke + this.data.partner.onchanges = { + foo: function(obj) { + obj.p = [ + [5], + [0, 0, {trululu: false}], + [0, 0, {trululu: false}], + ] + } + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'<form string="Partners">' + + '<field name="foo" />' + + '<field name="p">' + + '<tree editable="bottom" default_order="int_field">' + + '<field name="int_field" widget="handle"/>' + + '<field name="trululu"/>' + + '</tree>' + + '</field>' + + '</form>', + viewOptions: { + mode: 'create', + }, + mockRPC: function (route, args) { + assert.step(args.method + ' ' + args.model) + return this._super(route, args); + }, + }); + + // change the int_field through drag and drop + // that way, we'll trigger the sorting and the name_get + // of the lines of "p" + testUtils.dragAndDrop( + form.$('.ui-sortable-handle').eq(1), + form.$('tbody tr').first(), + {position: 'top'} + ); + + // Only those two should have been called + // name_get on trululu would trigger an traceback + assert.verifySteps(['default_get partner', 'onchange partner']); + + form.destroy(); + }); + QUnit.test('O2M List with pager, decoration and default_order: add and cancel adding', function (assert) { assert.expect(3); |
