diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-08-16 11:02:49 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-08-23 06:28:35 +0000 |
| commit | 1824020cc274f3ef6e86fec5248d49ffde86e480 (patch) | |
| tree | cdf0b6784518f35cef9246a5fe78d804128bb001 /addons/web/static/tests/fields/relational_fields | |
| parent | 4393b012a5417e0964ef11a3ac81496cacd3b812 (diff) | |
[IMP] web: list: keep columns width when adding records
Mainly, when adding the first record to the list, as this is when
we switch from forcing the column's widths (when there is no data),
to letting the browser optimally divide the available space.
Some other cases had to be handled, like the multi edition.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields/field_one2many_tests.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js index f4752bc9751..e8d8785b77a 100644 --- a/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js +++ b/addons/web/static/tests/fields/relational_fields/field_one2many_tests.js @@ -8541,6 +8541,71 @@ QUnit.module('fields', {}, function () { form.destroy(); }); + QUnit.test('column widths are kept when adding first record in o2m', async function (assert) { + assert.expect(2); + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="p">' + + '<tree editable="top">' + + '<field name="date"/>' + + '<field name="foo"/>' + + '</tree>' + + '</field>' + + '</form>', + }); + + var width = form.$('th[data-name="date"]')[0].offsetWidth; + + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a')); + + assert.containsOnce(form, '.o_data_row'); + assert.strictEqual(form.$('th[data-name="date"]')[0].offsetWidth, width); + + form.destroy(); + }); + + QUnit.test('column widths are kept when editing a record in o2m', async function (assert) { + assert.expect(2); + + this.data.partner.records[0].p = [2]; + + var form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="p">' + + '<tree editable="top">' + + '<field name="date"/>' + + '<field name="foo"/>' + + '</tree>' + + '</field>' + + '</form>', + res_id: 1, + viewOptions: { + mode: 'edit', + }, + }); + + var width = form.$('th[data-name="date"]')[0].offsetWidth; + + await testUtils.dom.click(form.$('.o_data_row .o_data_cell:first')); + + assert.strictEqual(form.$('th[data-name="date"]')[0].offsetWidth, width); + + var longVal = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed blandit, ' + + 'justo nec tincidunt feugiat, mi justo suscipit libero, sit amet tempus ipsum ' + + 'purus bibendum est.'; + await testUtils.fields.editInput(form.$('.o_field_widget[name=foo]'), longVal); + + assert.strictEqual(form.$('th[data-name="date"]')[0].offsetWidth, width); + + form.destroy(); + }); }); }); }); |
