diff --git a/web_widget_prefixed_url/README.rst b/web_widget_prefixed_url/README.rst new file mode 100644 index 000000000..a1bbca9be --- /dev/null +++ b/web_widget_prefixed_url/README.rst @@ -0,0 +1,39 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :alt: License: AGPL-3 + +======================================================== +Module for adding 'prefixed_url' widget to your fields. +======================================================== + +Using this widget user can add any hyperlink action using field option. + +Usage +===== + +.. code-block:: xml + + + +Credits +======= + +Contributors +------------ + +* Jay Vora +* Swapnesh Shah + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_widget_prefixed_url/__init__.py b/web_widget_prefixed_url/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_widget_prefixed_url/__manifest__.py b/web_widget_prefixed_url/__manifest__.py new file mode 100644 index 000000000..8fb3ffa80 --- /dev/null +++ b/web_widget_prefixed_url/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2019 - TODAY Serpent Consulting Services Pvt. Ltd. +# () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': "Web Widget Prefixed URL", + 'version': "11.0.1.0.0", + 'author': "Serpent Consulting Services Pvt. Ltd., " + "Odoo Community Association (OCA)", + 'category': 'Web', + 'website': "https://github.com/OCA/web", + 'license': 'AGPL-3', + 'depends': [ + 'web' + ], + 'data': [ + 'views/template.xml', + ], +} diff --git a/web_widget_prefixed_url/static/description/icon.png b/web_widget_prefixed_url/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_prefixed_url/static/description/icon.png differ diff --git a/web_widget_prefixed_url/static/src/js/widget_prefixed_url.js b/web_widget_prefixed_url/static/src/js/widget_prefixed_url.js new file mode 100644 index 000000000..5caa2818f --- /dev/null +++ b/web_widget_prefixed_url/static/src/js/widget_prefixed_url.js @@ -0,0 +1,30 @@ +odoo.define('web_widget_prefixed_url.WidgetPrefixedUrlCustom', function (require) { + "use strict"; + + var field_registry = require('web.field_registry'); + var basic_fields = require('web.basic_fields'); + + var WidgetPrefixedUrlCustom = basic_fields.FieldEmail.extend({ + + /** + * In readonly, emails should be a mailto: link with proper formatting. + * + * @override + * @private + */ + _renderReadonly: function () { + if (_.isEmpty(this.attrs.options.prefix_name)) { + this.$el.text(this.value); + } else { + var prefix = this.attrs.options.prefix_name; + this.$el.text(this.value) + .addClass('o_form_uri o_text_overflow') + .attr('href', prefix + ':' + this.value); + } + }, + }); + + field_registry.add('prefixed_url', WidgetPrefixedUrlCustom); + + return WidgetPrefixedUrlCustom; +}); diff --git a/web_widget_prefixed_url/views/template.xml b/web_widget_prefixed_url/views/template.xml new file mode 100644 index 000000000..81ef53a04 --- /dev/null +++ b/web_widget_prefixed_url/views/template.xml @@ -0,0 +1,11 @@ + + +