From 7c07a73b6c63630d410f2ae795bd461371440afe Mon Sep 17 00:00:00 2001 From: luvi Date: Mon, 19 Jun 2023 07:16:39 +0000 Subject: [PATCH] [FIX] web,*: properly format phone href *: mail This commit fixes the href used by the PhoneField. Following the specs of a phone uri, spaces must be removed from the phone number when using the href attribute. A test has been added to verify that any spaces are removed from a given phone number. In mail, the SMS button href has been edited for the same purpose. task-3371999 closes odoo/odoo#128383 X-original-commit: 9ff0270c8acf9596ebd404627c4f5b1a98b37c59 Signed-off-by: Florent Dardenne (dafl) Signed-off-by: Luca Vitali (luvi) --- .../src/components/sms_button/sms_button.js | 3 +++ .../src/components/sms_button/sms_button.xml | 2 +- .../src/views/fields/phone/phone_field.js | 3 +++ .../src/views/fields/phone/phone_field.xml | 4 +-- .../tests/views/fields/phone_field_tests.js | 27 +++++++++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/addons/sms/static/src/components/sms_button/sms_button.js b/addons/sms/static/src/components/sms_button/sms_button.js index b9337a88295..c435009d6cc 100644 --- a/addons/sms/static/src/components/sms_button/sms_button.js +++ b/addons/sms/static/src/components/sms_button/sms_button.js @@ -10,6 +10,9 @@ export class SendSMSButton extends Component { this.user = useService("user"); this.title = this.env._t("Send SMS Text Message"); } + get phoneHref() { + return "sms:" + this.props.record.data[this.props.name].replace(/\s+/g, ""); + } async onClick() { await this.props.record.save(); this.action.doAction({ diff --git a/addons/sms/static/src/components/sms_button/sms_button.xml b/addons/sms/static/src/components/sms_button/sms_button.xml index 3c08231c1bb..3598b4c5105 100644 --- a/addons/sms/static/src/components/sms_button/sms_button.xml +++ b/addons/sms/static/src/components/sms_button/sms_button.xml @@ -4,7 +4,7 @@ SMS diff --git a/addons/web/static/src/views/fields/phone/phone_field.js b/addons/web/static/src/views/fields/phone/phone_field.js index c7a3667a0f2..3f1eb01366d 100644 --- a/addons/web/static/src/views/fields/phone/phone_field.js +++ b/addons/web/static/src/views/fields/phone/phone_field.js @@ -17,6 +17,9 @@ export class PhoneField extends Component { setup() { useInputField({ getValue: () => this.props.record.data[this.props.name] || "" }); } + get phoneHref() { + return "tel:" + this.props.record.data[this.props.name].replace(/\s+/g, ""); + } } export const phoneField = { 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 844122c74bf..452ac79e3a3 100644 --- a/addons/web/static/src/views/fields/phone/phone_field.xml +++ b/addons/web/static/src/views/fields/phone/phone_field.xml @@ -4,7 +4,7 @@