From 170c7632f2dca698f01f466ee9d4fb154e71dd81 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Mon, 11 Mar 2019 11:43:53 +0000 Subject: [PATCH] [FIX] web: hide handle on readonly x2m The widget handle was displayed on x2m fields in form views, even when the field was readonly, which makes no sense. It is now correctly hidden. Fixes #30580 opw-1937833 closes odoo/odoo#31743 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/less/form_view.less | 3 ++ .../tests/fields/relational_fields_tests.js | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/addons/web/static/src/less/form_view.less b/addons/web/static/src/less/form_view.less index c0bb80b7a12..b32bca658f0 100644 --- a/addons/web/static/src/less/form_view.less +++ b/addons/web/static/src/less/form_view.less @@ -591,6 +591,9 @@ &.o_form_readonly .o_field_widget .o_list_view .o_row_handle { display: none; // Hide the handler in non-edit mode } + .o_field_widget.o_readonly_modifier .o_list_view .o_row_handle { + display: none; // Hide the handler on readonly fields + } // Attachments .oe_attachment { diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 421cee8a4b1..25b8e08e46d 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -3487,6 +3487,43 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('embedded readonly one2many with handle widget', function (assert) { + assert.expect(4); + + this.data.partner.records[0].turtles = [1, 2, 3]; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + res_id: 1, + }); + + assert.strictEqual(form.$('.o_row_handle').length, 3, + "there should be 3 handles (one for each row)"); + assert.strictEqual(form.$('.o_row_handle:visible').length, 0, + "the handles should be hidden in readonly mode"); + + form.$buttons.find('.o_form_button_edit').click(); + + assert.strictEqual(form.$('.o_row_handle').length, 3, + "the handles should still be there"); + assert.strictEqual(form.$('.o_row_handle:visible').length, 0, + "the handles should still be hidden (on readonly fields)"); + + form.destroy(); + }); + QUnit.test('onchange for embedded one2many in a one2many with a second page', function (assert) { assert.expect(1);