diff options
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 8 |
1 files changed, 7 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 0d1fc77737f..996e759a70a 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1528,6 +1528,7 @@ var UrlWidget = InputField.extend({ init: function () { this._super.apply(this, arguments); this.tagName = this.mode === 'readonly' ? 'a' : 'input'; + this.websitePath = this.nodeOptions.website_path || false; }, //-------------------------------------------------------------------------- @@ -1555,10 +1556,15 @@ var UrlWidget = InputField.extend({ * @private */ _renderReadonly: function () { + let href = this.value; + if (this.value && !this.websitePath) { + const regex = /^(?:[fF]|[hH][tT])[tT][pP][sS]?:\/\//; + href = !regex.test(this.value) ? `http://${href}` : href; + } this.$el.text(this.attrs.text || this.value) .addClass('o_form_uri o_text_overflow') .attr('target', '_blank') - .attr('href', this.value); + .attr('href', href); }, //-------------------------------------------------------------------------- |
