summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-09-30 15:55:39 +0200
committerAaron Bohy <aab@odoo.com>2017-09-30 17:33:20 +0200
commit5164d30c922e3d2eba6db5764ee6035a64629d00 (patch)
tree5caac6ec6f5d5f452bc0e6435f4cdaf009a80797 /addons/web/static/tests/fields/relational_fields_tests.js
parent1cded676199bd39b2b0a477f16fd5eb39c691c3b (diff)
[FIX] web: correctly redraw x2m list after onchange
When an onchange is set on an x2many field displayed as an editable list in a form view, and the user updates one of the subrecords, the updated subrecord is kept in the DOM and updated, and all other subrecords in the relation are re-rendered and re-inserted at their correct place in the list (because the onchange might have changed them). Before this rev., the order of the subrecords after the edited one was reversed.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index a96e21cc443..bb7dc5db00e 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -3689,6 +3689,44 @@ QUnit.module('relational_fields', {
AbstractField.prototype.destroy = oldDestroy;
});
+ QUnit.test('one2many editable list with onchange keeps the order', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.records[0].p = [1, 2, 4];
+ this.data.partner.onchanges = {
+ p: function () {},
+ };
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners">' +
+ '<field name="p">' +
+ '<tree editable="bottom">' +
+ '<field name="display_name"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ assert.strictEqual(form.$('.o_data_cell').text(), 'first recordsecond recordaaa',
+ "records should be display in the correct order");
+
+ form.$('.o_data_row:first .o_data_cell').click();
+ form.$('.o_selected_row .o_field_widget[name=display_name]').val('new').trigger('input');
+ form.$el.click(); // click outside to validate the row
+
+ assert.strictEqual(form.$('.o_data_cell').text(), 'newsecond recordaaa',
+ "records should be display in the correct order");
+
+ form.destroy();
+ });
+
QUnit.test('one2many list (editable): readonly domain is evaluated', function (assert) {
assert.expect(2);