Browse Source

[MIG] web_widget_image_url: Migration to 12.0.

pull/1145/head
Anand Kansagra 6 years ago
parent
commit
03c8d6a3bd
  1. 2
      web_widget_image_url/README.rst
  2. 1
      web_widget_image_url/__init__.py
  3. 2
      web_widget_image_url/__manifest__.py
  4. 3
      web_widget_image_url/readme/CONTRIBUTORS.rst
  5. 1
      web_widget_image_url/readme/DESCRIPTION.rst
  6. 1
      web_widget_image_url/readme/USAGE.rst
  7. 10
      web_widget_image_url/static/src/js/web_widget_image_url.js
  8. 2
      web_widget_image_url/static/src/xml/web_widget_image_url.xml

2
web_widget_image_url/README.rst

@ -38,7 +38,7 @@ Contributors
* Petar Najman <petar.najman@modoolar.com> * Petar Najman <petar.najman@modoolar.com>
* Sladjan Kantar <sladjan.kantar@modoolar.com> * Sladjan Kantar <sladjan.kantar@modoolar.com>
* Anand Kansagra <kansagraanand@hotmail.com>
Maintainer Maintainer
---------- ----------

1
web_widget_image_url/__init__.py

@ -0,0 +1 @@
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).

2
web_widget_image_url/__manifest__.py

@ -4,7 +4,7 @@
"name": "Web Image URL", "name": "Web Image URL",
"summary": "This module provides web widget for displaying image from URL", "summary": "This module provides web widget for displaying image from URL",
"category": "Web", "category": "Web",
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Modoolar, Odoo Community Association (OCA)", "author": "Modoolar, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web/", "website": "https://github.com/OCA/web/",

3
web_widget_image_url/readme/CONTRIBUTORS.rst

@ -0,0 +1,3 @@
* Petar Najman <petar.najman@modoolar.com>
* Sladjan Kantar <sladjan.kantar@modoolar.com>
* Anand Kansagra <kansagraanand@hotmail.com>

1
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.

1
web_widget_image_url/readme/USAGE.rst

@ -0,0 +1 @@
To use this module, you need to decorate xml field with widget ``image_url``.

10
web_widget_image_url/static/src/js/web_widget_image_url.js

@ -7,7 +7,6 @@ odoo.define('web_widget_image_url.FieldImageURL', function (require) {
var AbstractField = require('web.AbstractField'); var AbstractField = require('web.AbstractField');
var core = require('web.core'); var core = require('web.core');
var registry = require('web.field_registry'); var registry = require('web.field_registry');
var QWeb = core.qweb;
var _t = core._t; var _t = core._t;
var UrlImage = AbstractField.extend({ var UrlImage = AbstractField.extend({
@ -16,20 +15,21 @@ odoo.define('web_widget_image_url.FieldImageURL', function (require) {
placeholder: "/web/static/src/img/placeholder.png", placeholder: "/web/static/src/img/placeholder.png",
supportedFieldTypes: ['char'], supportedFieldTypes: ['char'],
url(){
url: function () {
return this.value ? this.value : this.placeholder; return this.value ? this.value : this.placeholder;
}, },
_render() {
_render: function () {
this._super(arguments); this._super(arguments);
var self = this; var self = this;
var $img = this.$("img:first"); var $img = this.$("img:first");
$img.on('error', function () { $img.on('error', function () {
$img.attr('src', self.placeholder); $img.attr('src', self.placeholder);
self.do_warn(_t("Image"), _t("Could not display the selected image."));
self.do_warn(
_t("Image"), _t("Could not display the selected image."));
}); });
}
},
}); });
registry.add('image_url', UrlImage); registry.add('image_url', UrlImage);

2
web_widget_image_url/static/src/xml/web_widget_image_url.xml

@ -7,7 +7,7 @@
<t t-name="FieldImageURL"> <t t-name="FieldImageURL">
<span class="oe_form_field oe_form_field_image" t-att-style="widget.attrs.style"> <span class="oe_form_field oe_form_field_image" t-att-style="widget.attrs.style">
<img t-att-src="widget.url()" <img t-att-src="widget.url()"
t-att-border="widget.readonly ? 0 : 1"
t-att-style="(!widget.readonly ? 'border: 0' : 'border: 1')"
t-att-name="widget.name" t-att-name="widget.name"
t-att-width="widget.attrs.img_width || widget.attrs.width" t-att-width="widget.attrs.img_width || widget.attrs.width"
t-att-height="widget.attrs.img_height || widget.attrs.height" t-att-height="widget.attrs.img_height || widget.attrs.height"

Loading…
Cancel
Save