summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-09-15 10:19:16 +0200
committerfwi-odoo <fwi@odoo.com>2017-09-29 16:49:20 +0200
commitda136d83bb4cd952dc0e2417d67679cfc5068f34 (patch)
treed149d19de2188ecd5f5aff05bea09c6201e78211 /addons/web/static/tests/fields/relational_fields_tests.js
parenta7d1740e475c44b50d0cc6ce6f43e9f142e99334 (diff)
[IMP] web: x2m list: conditionnaly hide a column
This commit introduces a new way to hide a column in a x2m list view. The attribute 'tree_invisible' can be add in the field attrs in the x2m view definition. This attribute can use the 'parent' key to make a reference to the parent record (e.g. 'parent.id').
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js34
1 files changed, 34 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 c5b4001e087..8cf0e20037e 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -8351,6 +8351,40 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('one2many invisible depends on parent field', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.records[0].p = [2];
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch:'<form string="Partners">' +
+ '<sheet>' +
+ '<notebook>' +
+ '<page string="Partner page">' +
+ '<field name="bar"/>' +
+ '<field name="p">' +
+ '<tree>' +
+ '<field name="foo"/>' +
+ '<field name="bar" attrs="{\'column_invisible\': [(\'parent.bar\', \'=\', False)]}"/>' +
+ '</tree>' +
+ '</field>' +
+ '</page>' +
+ '</notebook>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ });
+ assert.strictEqual(form.$('th').length, 2,
+ "should be 2 columns in the one2many");
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('.o_field_boolean[name="bar"] input').click();
+ assert.strictEqual(form.$('th').length, 1,
+ "should be 1 column after the value change");
+ form.destroy();
+ });
+
});
});
});