summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorDebauche Stéphane <std@odoo.com>2020-01-20 14:28:35 +0000
committerThibault Delavallée <tde@odoo.com>2020-01-28 09:14:43 +0000
commit75f7ab0608bfb9770e99fe2ce1ad55e76c70ac72 (patch)
tree16654596a1fc75b24e71c56f56d27a65b96f5739 /addons/web/static
parent1ec887b773581b6316902997fec94176bbae1ac0 (diff)
[FIX] web: fix email and phone widgets with empty value
When the value is empty in a related field, string of the element was displaying "false" instead of an empty string which is not what we expect. This commit fixes that issue. Task ID 2119333 PR #40949
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js10
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js25
2 files changed, 32 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 3be9b68cd0d..0d1fc77737f 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1465,9 +1465,13 @@ var FieldEmail = InputField.extend({
* @private
*/
_renderReadonly: function () {
- this.$el.text(this.value)
- .addClass('o_form_uri o_text_overflow')
- .attr('href', this.prefix + ':' + this.value);
+ if (this.value) {
+ this.$el.text(this.value)
+ .addClass('o_form_uri o_text_overflow')
+ .attr('href', this.prefix + ':' + this.value);
+ } else {
+ this.$el.text('');
+ }
},
//--------------------------------------------------------------------------
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 21e8ef25159..ede054eb5a9 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -31,6 +31,7 @@ QUnit.module('basic_fields', {
display_name: {string: "Displayed name", type: "char", searchable: true},
foo: {string: "Foo", type: "char", default: "My little Foo Value", searchable: true, trim: true},
bar: {string: "Bar", type: "boolean", default: true, searchable: true},
+ empty_string: {string: "Empty string", type: "char", default: false, searchable: true, trim: true},
txt: {string: "txt", type: "text", default: "My little txt Value\nHo-ho-hoooo Merry Christmas"},
int_field: {string: "int_field", type: "integer", sortable: true, searchable: true},
qux: {string: "Qux", type: "float", digits: [16,1], searchable: true},
@@ -996,6 +997,30 @@ QUnit.module('basic_fields', {
list.destroy();
});
+ QUnit.test('email field with empty value', async function (assert) {
+ assert.expect(1);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<group>' +
+ '<field name="empty_string" widget="email"/>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ });
+
+ var $mailtoLink = form.$('a.o_form_uri.o_field_widget.o_text_overflow');
+ assert.strictEqual($mailtoLink.text(), '',
+ "the value should be displayed properly");
+
+ form.destroy();
+ });
+
QUnit.module('FieldChar');