From fd3c3821861dcfecdd63079c799863002fd67d71 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Mon, 16 Sep 2019 11:49:00 +0000 Subject: [FIX] web: field color: adapted for views The FieldColor widget had been designed exclusively for the document layout configurator. Because of this, the widget would not display/behave correctly in other views. Before this commit: - in list views, the widget had a "white-space" attribute adapted for char fields, which gave it much more space than it needed - there was no handling of the widget in readonly state: it was always editable - its size in list views was a bit too large Now: - all styling problems have been adjusted for list views (unchanged for forms) - the widget is disabled when in readonly mode Task 2072466 closes odoo/odoo#36949 Signed-off-by: VincentSchippefilt --- .../web/static/tests/fields/basic_fields_tests.js | 42 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 63ce02be614..1d91f581317 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -6442,7 +6442,7 @@ QUnit.module('basic_fields', { }); QUnit.test('Field Color: default widget state', async function (assert) { - assert.expect(3); + assert.expect(4); var form = await createView({ View: FormView, @@ -6467,6 +6467,46 @@ QUnit.module('basic_fields', { await testUtils.dom.click($('.modal .btn:contains("Discard")')); + assert.strictEqual(document.activeElement, form.$('.o_field_color')[0], + "Focus should go back to the color field"); + + form.destroy(); + }); + + QUnit.test('Field Color: behaviour in different views', async function (assert) { + assert.expect(2); + + this.data.partner.records[0].p = [4, 2]; + this.data.partner.records[1].hex_color = '#ff0080'; + + const form = await createView({ + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '', + data: this.data, + model: 'partner', + res_id: 1, + View: FormView, + }); + + await testUtils.dom.click(form.$('.o_field_color:first()')); + assert.containsNone($(document.body), '.modal', + "Color field in readonly shouldn't be editable"); + + const rowInitialHeight = form.$('.o_data_row:first()').height(); + + await testUtils.form.clickEdit(form); + await testUtils.dom.click(form.$('.o_data_row:first() .o_data_cell:first()')); + + assert.strictEqual(rowInitialHeight, form.$('.o_data_row:first()').height(), + "Color field shouldn't change the color height when edited"); + form.destroy(); }); -- cgit v1.2.3