diff --git a/web_widget_image_url/README.rst b/web_widget_image_url/README.rst new file mode 100644 index 000000000..abaff473a --- /dev/null +++ b/web_widget_image_url/README.rst @@ -0,0 +1,56 @@ +.. image:: https://www.gnu.org/graphics/lgplv3-147x51.png + :target: https://www.gnu.org/licenses/lgpl-3.0.en.html + :alt: License: LGPL-v3 + +============= +Web Image URL +============= + +This module provides web widget for displaying image from URL on form and tree views. + +Usage +===== + +To use this module, you need to decorate xml field with widget ``image_url``. + + +.. code-block:: xml + + + +Here's an examples of how images looks like on a form + +.. figure:: static/description/image.png + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Petar Najman +* Sladjan Kantar +* Anand Kansagra + +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_image_url/__init__.py b/web_widget_image_url/__init__.py new file mode 100644 index 000000000..9a20a1564 --- /dev/null +++ b/web_widget_image_url/__init__.py @@ -0,0 +1 @@ +# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). diff --git a/web_widget_image_url/__manifest__.py b/web_widget_image_url/__manifest__.py new file mode 100644 index 000000000..205a59fbc --- /dev/null +++ b/web_widget_image_url/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2017 - 2018 Modoolar +# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). +{ + "name": "Web Image URL", + "summary": "This module provides web widget for displaying image from URL", + "category": "Web", + "version": "12.0.1.0.0", + "license": "LGPL-3", + "author": "Modoolar, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web/", + "depends": ["web"], + "data": [ + "views/web_widget_image_url.xml", + ], + "qweb": ["static/src/xml/*.xml"], + "installable": True, +} diff --git a/web_widget_image_url/i18n/web_widget_image_url.pot b/web_widget_image_url/i18n/web_widget_image_url.pot new file mode 100644 index 000000000..556b5614e --- /dev/null +++ b/web_widget_image_url/i18n/web_widget_image_url.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_image_url +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_widget_image_url +#. openerp-web +#: code:addons/web_widget_image_url/static/src/js/web_widget_image_url.js:30 +#, python-format +msgid "Could not display the selected image." +msgstr "" + +#. module: web_widget_image_url +#. openerp-web +#: code:addons/web_widget_image_url/static/src/js/web_widget_image_url.js:30 +#, python-format +msgid "Image" +msgstr "" + diff --git a/web_widget_image_url/readme/CONTRIBUTORS.rst b/web_widget_image_url/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..b22a1d328 --- /dev/null +++ b/web_widget_image_url/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Petar Najman +* Sladjan Kantar +* Anand Kansagra diff --git a/web_widget_image_url/readme/DESCRIPTION.rst b/web_widget_image_url/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f4be39cf8 --- /dev/null +++ b/web_widget_image_url/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module provides web widget for displaying image from URL on form and tree views. diff --git a/web_widget_image_url/readme/USAGE.rst b/web_widget_image_url/readme/USAGE.rst new file mode 100644 index 000000000..69bf931f3 --- /dev/null +++ b/web_widget_image_url/readme/USAGE.rst @@ -0,0 +1 @@ +To use this module, you need to decorate xml field with widget ``image_url``. diff --git a/web_widget_image_url/static/description/icon.png b/web_widget_image_url/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_image_url/static/description/icon.png differ diff --git a/web_widget_image_url/static/description/image.png b/web_widget_image_url/static/description/image.png new file mode 100644 index 000000000..bfd0522c9 Binary files /dev/null and b/web_widget_image_url/static/description/image.png differ diff --git a/web_widget_image_url/static/src/js/web_widget_image_url.js b/web_widget_image_url/static/src/js/web_widget_image_url.js new file mode 100644 index 000000000..b9d1a2000 --- /dev/null +++ b/web_widget_image_url/static/src/js/web_widget_image_url.js @@ -0,0 +1,36 @@ +// Copyright 2017 - 2018 Modoolar +// License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). + +odoo.define('web_widget_image_url.FieldImageURL', function (require) { + "use strict"; + + var AbstractField = require('web.AbstractField'); + var core = require('web.core'); + var registry = require('web.field_registry'); + var _t = core._t; + + var UrlImage = AbstractField.extend({ + className: 'o_attachment_image', + template: 'FieldImageURL', + placeholder: "/web/static/src/img/placeholder.png", + supportedFieldTypes: ['char'], + + url: function () { + return this.value ? this.value : this.placeholder; + }, + + _render: function () { + this._super(arguments); + + var self = this; + var $img = this.$("img:first"); + $img.on('error', function () { + $img.attr('src', self.placeholder); + self.do_warn( + _t("Image"), _t("Could not display the selected image.")); + }); + }, + }); + + registry.add('image_url', UrlImage); +}); diff --git a/web_widget_image_url/static/src/xml/web_widget_image_url.xml b/web_widget_image_url/static/src/xml/web_widget_image_url.xml new file mode 100644 index 000000000..8db6337eb --- /dev/null +++ b/web_widget_image_url/static/src/xml/web_widget_image_url.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/web_widget_image_url/views/web_widget_image_url.xml b/web_widget_image_url/views/web_widget_image_url.xml new file mode 100644 index 000000000..bb49a3cc9 --- /dev/null +++ b/web_widget_image_url/views/web_widget_image_url.xml @@ -0,0 +1,12 @@ + + + +