summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-04-13 14:30:46 +0200
committerNicolas Lempereur <nle@odoo.com>2018-04-13 15:35:33 +0200
commitb8b0f947bf7f7abf930a1797fa55c7f7dd33faa2 (patch)
treeae0637e8286815981eeffa4aceceac4322edda0f /addons/web/static
parent52cd52e624d987916ea62e566cc777505c13e469 (diff)
[FIX] web: remove &shy; when saving phone number
When Odoo display a phone number number, on phone or if VOIP is installed a invisible `&shy;` character was added from 9.0 up to saas-11.2 so an applications such as skype would not be concerned with the number. But if someone copy-pasted from this to somewhere else in Odoo, we would get incorrect number with this invisible caracter. So this change make a special case for the "FieldPhone" so the character is removed from data saved. opw-1834858 closes #24223
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js15
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js11
2 files changed, 25 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index eb0a4a2cdaf..aff339cb4a2 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1014,6 +1014,21 @@ var FieldPhone = FieldEmail.extend({
},
/**
+ * Remove possibly present &shy; characters when saving number
+ *
+ * @override
+ * @private
+ */
+ _setValue: function (value, options) {
+ // NOT NEEDED AS OF SAAS-11.3
+ if (value) {
+ // remove possibly pasted &shy; characters
+ value = value.replace(/\u00AD/g, '');
+ }
+ return this._super(value, options);
+ },
+
+ /**
* Phone fields are clickable in readonly on small screens ~= on phones.
* This can be overriden by call-capable modules to display a clickable
* link in different situations, like always regardless of screen size,
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index b924afce8d5..909e778b60a 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -3042,7 +3042,7 @@ QUnit.module('basic_fields', {
QUnit.module('PhoneWidget');
QUnit.test('phone field in form view on extra small screens', function (assert) {
- assert.expect(7);
+ assert.expect(8);
var form = createView({
View: FormView,
@@ -3090,6 +3090,15 @@ QUnit.module('basic_fields', {
assert.strictEqual($phoneLink.attr('href'), 'tel:new',
"should still have proper tel prefix");
+ // NOT NEEDED AS OF SAAS-11.3
+ // save phone with &shy; and verify it is removed
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('input[type="text"].o_field_widget').val('h\u00ADi').trigger('input');
+ form.$buttons.find('.o_form_button_save').click();
+ $phoneLink = form.$('a.o_form_uri.o_field_widget');
+ assert.strictEqual($phoneLink.attr('href'), 'tel:hi',
+ "U+00AD should have been removed");
+
form.destroy();
});