From cbdea4010ede6203f5f49d08d5a3bc44f2ff89e8 Mon Sep 17 00:00:00 2001 From: luvi Date: Fri, 9 Sep 2022 10:03:35 +0000 Subject: [PATCH] [FIX] web: hide the phone field if empty This commit hides the representing the phone number if it is unset. Before this commit, it could display "false" instead of being invisible. Now, the element is no longer added to the DOM. A test has been added to assert that behavior. closes odoo/odoo#99905 Signed-off-by: Aaron Bohy (aab) --- .../src/views/fields/phone/phone_field.xml | 2 +- .../tests/views/fields/phone_field_tests.js | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/fields/phone/phone_field.xml b/addons/web/static/src/views/fields/phone/phone_field.xml index f4f77c0b015..5596be1f3e6 100644 --- a/addons/web/static/src/views/fields/phone/phone_field.xml +++ b/addons/web/static/src/views/fields/phone/phone_field.xml @@ -3,7 +3,7 @@ - + { "Placeholder" ); }); + + QUnit.test("unset and readonly PhoneField", async function (assert) { + serverData.models.partner.fields.foo.default = false; + + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` +
+ + + + + +
`, + }); + assert.containsNone( + target.querySelector(".o_field_widget[name='foo']"), + "a", + "The readonly field don't contain a link if no value is set" + ); + }); });