summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorJinal Patel <jip@odoo.com>2019-07-30 06:19:09 +0000
committersvs-odoo <svs@odoo.com>2019-08-30 13:55:56 +0000
commit5a1fb85ef681d1197f22b7c1e2ed8a9fc2898cac (patch)
treef0ab158ea3aca33e2343d1c825ef14a3abc224da /addons/web/static/tests
parent50464f54613449be0f9be7b586e2810fc2da4403 (diff)
[FIX] web: support oe_read_only and oe_edit_only in x2m list
Back-ported from the master, commit ca9a733b27a1680403961eaa13cc62e5aa58a8fb Before this rev., classNames 'oe_read_only' (only display in readonly mode) and 'oe_edit_only' (only display in edit mode) didn't work in x2m lists inside form views (only the cells in the tbody were hidden, but not the header). This rev. makes this work. Task 1949618 closes odoo/odoo#36117 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> closes odoo/odoo#36285 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/views/form_tests.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 765beb7ed08..1c0c9ae9485 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -4627,6 +4627,83 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('oe_read_only className is handled in list views', async function (assert) {
+ assert.expect(5);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<field name="p">' +
+ '<tree editable="top">' +
+ '<field name="foo"/>' +
+ '<field name="display_name" class="oe_read_only"/>' +
+ '<field name="bar"/>' +
+ '</tree>' +
+ '</field>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ assert.hasClass(form.$('.o_form_view'), 'o_form_readonly',
+ 'form should be in readonly mode');
+ assert.isVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should be visible in readonly mode');
+
+ await testUtils.form.clickEdit(form);
+ assert.hasClass(form.$('.o_form_view'), 'o_form_editable',
+ 'form should be in edit mode');
+ assert.isNotVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should not be visible in edit mode');
+
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ assert.hasClass(form.$('.o_form_view .o_list_view tbody tr:first input[name="display_name"]'),
+ 'oe_read_only', 'display_name input should have oe_read_only class');
+
+ form.destroy();
+ });
+
+ QUnit.test('oe_edit_only className is handled in list views', async function (assert) {
+ assert.expect(5);
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<field name="p">' +
+ '<tree editable="top">' +
+ '<field name="foo"/>' +
+ '<field name="display_name" class="oe_edit_only"/>' +
+ '<field name="bar"/>' +
+ '</tree>' +
+ '</field>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ assert.hasClass(form.$('.o_form_view'), 'o_form_readonly',
+ 'form should be in readonly mode');
+ assert.isNotVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should not be visible in readonly mode');
+
+ await testUtils.form.clickEdit(form);
+ assert.hasClass(form.$('.o_form_view'), 'o_form_editable',
+ 'form should be in edit mode');
+ assert.isVisible(form.$('.o_field_one2many .o_list_view thead th[data-name="display_name"]'),
+ 'display_name cell should be visible in edit mode');
+
+ await testUtils.dom.click(form.$('.o_field_x2many_list_row_add a'));
+ assert.hasClass(form.$('.o_form_view .o_list_view tbody tr:first input[name="display_name"]'),
+ 'oe_edit_only', 'display_name input should have oe_edit_only class');
+
+ form.destroy();
+ });
+
QUnit.test('*_view_ref in context are passed correctly', async function (assert) {
var done = assert.async();
assert.expect(3);