From 58da62bcb01b7d023474a46ed5b4a3a4d43c2368 Mon Sep 17 00:00:00 2001 From: "Maruan Aguerdouh (magm)" Date: Mon, 31 Jul 2023 13:22:39 +0000 Subject: [PATCH] [FIX] web: image in worksheets not streched for safari Steps to reproduce: - Get Field Service app and the module for cutom worksheets. - Create a new worksheet template that contains images. - Create a new task with this template and go to the worksheet. - Add any image. Forcing the width to 100% breaks the view in safari since it's not going to respect the proportions, removing this will have good behavior in both safari and other browsers (chrome, firefox), also this will have the same behavior it used to have in 15.0. Be careful with adding this back in the future since when a user adds inside his worksheet an image field, studio set the default size to "small" value. (It's added an inline style with a widthset as "auto" and a height set as "90px") but the image_field API was broken with the w-100 added here[1]. It's seems not needed so we remove it to fix the api. [1]: https://github.com/odoo/odoo/commit/d1de396f2aa91a03732f0447d59a7306acae3129#diff-a9fcda7725e1ce88ca6deed7aff792476b26e264edc757b889e9dd3b94ea1dbfR33 opw-3415267 closes odoo/odoo#131808 X-original-commit: 740b560284e5c0987854f173437d7e4b3454caf5 Signed-off-by: Romain Estievenart (res) --- .../static/src/views/fields/image/image_field.xml | 2 +- .../tests/views/fields/image_field_tests.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/fields/image/image_field.xml b/addons/web/static/src/views/fields/image/image_field.xml index 06187d8004d..49c58008bae 100644 --- a/addons/web/static/src/views/fields/image/image_field.xml +++ b/addons/web/static/src/views/fields/image/image_field.xml @@ -31,7 +31,7 @@ Binary file { QUnit.module("ImageField"); QUnit.test("ImageField is correctly rendered", async function (assert) { - assert.expect(10); + assert.expect(12); serverData.models.partner.records[0].write_date = "2017-02-08 10:00:00"; serverData.models.partner.records[0].document = MY_IMAGE; @@ -143,6 +143,19 @@ QUnit.module("Fields", (hooks) => { "the image should correctly set its attributes" ); + const computedStyle = window.getComputedStyle( + target.querySelector(".o_field_widget[name='document'] img") + ); + assert.strictEqual( + computedStyle.width, + "90px", + "the image should correctly set its attributes" + ); + assert.strictEqual( + computedStyle.height, + "90px", + "the image should correctly set its attributes" + ); assert.containsOnce( target, ".o_field_image .o_select_file_button",