From 006c31b9558ee4bfb42b71e1130a3a8be48bc23e Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 25 Jun 2018 12:34:42 +0530 Subject: [FIX] web: re-evaluate column_invisible after onchange Let's assume a form view with field A and B (a one2many list), with a column with attrs column_invisible depending on A. If the user sets A manually, everything works fine (the column is hidden/shown directly). However, if A is updated by an onchange (e.g. depending on the number of rows in B), it doesn't. This rev. fixes that issue. Related to Issue: 1851451 Co-authored-by: Priyanka Kaakdiya --- .../static/tests/fields/relational_fields_tests.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index e9f08195ec1..9f3d73268f2 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -12812,6 +12812,53 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('one2many column visiblity depends on onchange of parent field', function (assert) { + assert.expect(3); + + this.data.partner.records[0].p = [2]; + this.data.partner.records[0].bar = false; + + this.data.partner.onchanges.p = function (obj) { + // set bar to true when line is added + if (obj.p.length > 1 && obj.p[1][2].foo === 'New line') { + obj.bar = true; + } + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '', + res_id: 1, + }); + + // bar is false so there should be 1 column + assert.strictEqual(form.$('th').length, 1, + "should be only 1 column ('foo') in the one2many"); + assert.strictEqual(form.$('.o_list_view .o_data_row').length, 1, "should contain one row"); + + form.$buttons.find('.o_form_button_edit').click(); + + // add a new o2m record + form.$('.o_field_x2many_list_row_add a').click(); + form.$('.o_field_one2many input:first').focus(); + form.$('.o_field_one2many input:first').val('New line').trigger('input'); + form.$el.click(); // click outside to save a line + + assert.strictEqual(form.$('th').length, 2, "should be 2 columns('foo' + 'int_field')"); + + form.destroy(); + }); + QUnit.test('one2many column_invisible on view not inline', function (assert) { assert.expect(4); -- cgit v1.2.3