From 1bd3bce8df3a892ab028e07ebdaa3dcef58c1eb0 Mon Sep 17 00:00:00 2001 From: "Adesh Jolhe (adjo)" Date: Wed, 19 Jan 2022 12:58:00 +0000 Subject: [PATCH] [FIX] web: fix the color_picker widget alignment issue Currently, when we go to the planning > config > resource (editable list view without any record) and create a ersaource the color picker widget is resized vertically instead of horizontally. In this commit we have fixed the issue, when there is no record in the planning_resources list view, the color_picker widget gets 72px width by default, so we have added a condition that if there is a color_picker widget in a field, we will calculate the width based on the total fields in the view. task-2720976 X-original-commit: d047080c18ea4c9314df5f2aefdfb6b7deeef45a Part-of: odoo/odoo#90897 --- .../src/legacy/js/fields/basic_fields.js | 2 +- .../static/tests/legacy/views/list_tests.js | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/fields/basic_fields.js b/addons/web/static/src/legacy/js/fields/basic_fields.js index 844cdf487a5..c5e42755d14 100644 --- a/addons/web/static/src/legacy/js/fields/basic_fields.js +++ b/addons/web/static/src/legacy/js/fields/basic_fields.js @@ -4075,7 +4075,7 @@ var FieldColorPicker = FieldInteger.extend({ _t('Green'), _t('Purple'), ], - + widthInList: '1', /** * Prepares the rendering, since we are based on an input but not using it * setting tagName after parent init force the widget to not render an input diff --git a/addons/web/static/tests/legacy/views/list_tests.js b/addons/web/static/tests/legacy/views/list_tests.js index 54a355fa1df..17396540bfa 100644 --- a/addons/web/static/tests/legacy/views/list_tests.js +++ b/addons/web/static/tests/legacy/views/list_tests.js @@ -12808,6 +12808,30 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('FieldColorPicker: dont overflow color picker in list', async function (assert) { + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: ` + + + + `, + domain: [['id', '<', 0]], + }); + await testUtils.dom.click(list.el.querySelector('.o_list_button_add')) + const date_column_width = list.el.querySelector('.o_list_table thead th[data-name="date"]').style.width.replace('px', ''); + const int_field_column_width = list.el.querySelector('.o_list_table thead th[data-name="int_field"]').style.width.replace('px', ''); + // Default values for date and int fields are: date: '92px', integer: '74px' + // With the screen growing, the proportion is kept and thus int_field would remain smaller than date if + // the color_picker wouldn't have widthInList set to '1'. With that property set, int_field size will be bigger + // than date's one. + assert.ok(parseFloat(date_column_width) < parseFloat(int_field_column_width), "colorpicker should display properly (Horizontly)"); + list.destroy(); + }); + + }); });