summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorMohammed Shekha <msh@openerp.com>2018-06-25 12:34:42 +0530
committerAaron Bohy <aab@odoo.com>2018-11-05 13:57:39 +0100
commit006c31b9558ee4bfb42b71e1130a3a8be48bc23e (patch)
tree274db0720ea0099466de74b0d815302bc046a3f4 /addons/web/static/tests/fields/relational_fields_tests.js
parent60cdd13eb31add73124e99d3d7f0963ab8df2c57 (diff)
[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 <pka@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js47
1 files changed, 47 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 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:'<form>' +
+ '<field name="bar"/>' +
+ '<field name="p">' +
+ '<tree editable="bottom">' +
+ '<field name="foo"/>' +
+ '<field name="int_field" attrs="{\'column_invisible\': [(\'parent.bar\', \'=\', False)]}"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ 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);