Rodney Elpidio Enciso Arias 6 éve
commit
c67b078004
18 módosított fájl, 510 hozzáadás és 0 törlés
  1. 56 0
      README.rst
  2. 0 0
      __init__.py
  3. BIN
      __init__.pyc
  4. 41 0
      __openerp__.py
  5. 26 0
      i18n/ar.po
  6. 26 0
      i18n/de.po
  7. 26 0
      i18n/es.po
  8. 26 0
      i18n/fi.po
  9. 26 0
      i18n/fr.po
  10. 26 0
      i18n/hr.po
  11. 26 0
      i18n/it.po
  12. 26 0
      i18n/pt_BR.po
  13. 26 0
      i18n/sl.po
  14. 26 0
      i18n/tr.po
  15. BIN
      static/description/icon.png
  16. 104 0
      static/src/js/web_tree_image.js
  17. 39 0
      static/src/xml/widget.xml
  18. 10 0
      view/assets.xml

+ 56 - 0
README.rst

@@ -0,0 +1,56 @@
+.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
+    :alt: License: AGPL-3
+
+=====================================
+Display images and icons in tree view
+=====================================
+
+This module defines a tree image widget, to be used with either binary fields
+or (function) fields of type character. Use ``widget='image'`` in your view
+definition. Optionally, set a ``height`` attribute. Default height is 16px.
+
+If you use the widget with a character field, the content of the field can be
+any of the following:
+
+* The absolute or relative location of an image. For example,
+  "/<module>/static/src/img/youricon.png"
+
+* A standard icon from the web distribution, without path or extension, For
+  example, 'gtk-open'
+
+* A dynamic image in a data url base 64 format. Prefix with
+  'data:image/png;base64,'
+
+Usage
+=====
+
+This module defines a new widget type for tree views columns.
+
+Set the attribute ``widget=image`` in a ``field`` tag in a tree view.
+You can also set ``height=<height>`` to set the height the image will have.
+Note that this just sets the image ``height`` attribute,
+if you want to make the server return a resized image, maybe to reduce the size
+of the transferred file or to have uniform images, use the
+``resize="<width>,<height>"`` attribute.
+
+You can set ``display=icon`` in order to get a clickable picture icon that will
+open a full screen preview of the image. Set ``display=thumbnail`` to get a
+clickable thumbnail.
+
+Credits
+=======
+
+Contributors
+------------
+
+* Stefan Rijnhart
+* Leonardo Donelli <donelli@webmonks.it>
+
+Maintainer
+----------
+
+.. image:: https://odoo-community.org/logo.png
+   :alt: Odoo Community Association
+   :target: https://odoo-community.org
+
+This module is maintained by the OCA.

+ 0 - 0
__init__.py


BIN
__init__.pyc


+ 41 - 0
__openerp__.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    This module copyright (C) 2014 Therp BV (<http://therp.nl>).
+#    copyright (C) 2015 Leonardo Donelli @ MONKSoftware
+#
+#    Snippet from https://github.com/hsd/listview_images
+#    Copyright (C) 2013 Marcel van der Boom <marcel@hsdev.com>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Show images in tree views',
+    'version': '8.0.1.1.0',
+    'author': 'Therp BV, MONK Software, Odoo Community Association (OCA)',
+    'website': 'https://github.com/OCA/Web',
+    'license': 'AGPL-3',
+    'category': 'Web',
+    'depends': [
+        'web',
+    ],
+    'qweb': [
+        'static/src/xml/widget.xml',
+    ],
+    'data': [
+        'view/assets.xml',
+    ],
+}

+ 26 - 0
i18n/ar.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# SaFi J. <safi2266@gmail.com>, 2015
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-12-16 07:41+0000\n"
+"PO-Revision-Date: 2015-12-16 17:23+0000\n"
+"Last-Translator: SaFi J. <safi2266@gmail.com>\n"
+"Language-Team: Arabic (http://www.transifex.com/oca/OCA-web-8-0/language/ar/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: ar\n"
+"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "معاينة الصورة"

+ 26 - 0
i18n/de.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Rudolf Schnapka <rs@techno-flex.de>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-10 07:31+0000\n"
+"PO-Revision-Date: 2016-01-18 20:15+0000\n"
+"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
+"Language-Team: German (http://www.transifex.com/oca/OCA-web-8-0/language/de/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: de\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Bildvorschau"

+ 26 - 0
i18n/es.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Antonio Trueba, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-10 07:31+0000\n"
+"PO-Revision-Date: 2016-02-10 16:42+0000\n"
+"Last-Translator: Antonio Trueba\n"
+"Language-Team: Spanish (http://www.transifex.com/oca/OCA-web-8-0/language/es/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: es\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Vista previa"

+ 26 - 0
i18n/fi.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-10 07:31+0000\n"
+"PO-Revision-Date: 2016-02-01 09:53+0000\n"
+"Last-Translator: Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>\n"
+"Language-Team: Finnish (http://www.transifex.com/oca/OCA-web-8-0/language/fi/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: fi\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Kuvan esikatselu"

+ 26 - 0
i18n/fr.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-05-06 15:50+0000\n"
+"PO-Revision-Date: 2016-05-06 08:19+0000\n"
+"Last-Translator: Christophe CHAUVET <christophe.chauvet@gmail.com>\n"
+"Language-Team: French (http://www.transifex.com/oca/OCA-web-8-0/language/fr/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: fr\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Prévisualisation de l'image"

+ 26 - 0
i18n/hr.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-08-25 00:51+0000\n"
+"PO-Revision-Date: 2016-08-19 11:48+0000\n"
+"Last-Translator: Ana-Maria Olujić <ana-maria.olujic@slobodni-programi.hr>\n"
+"Language-Team: Croatian (http://www.transifex.com/oca/OCA-web-8-0/language/hr/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: hr\n"
+"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Pregled slike"

+ 26 - 0
i18n/it.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Paolo Valier, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-03-17 07:30+0000\n"
+"PO-Revision-Date: 2016-03-19 10:10+0000\n"
+"Last-Translator: Paolo Valier\n"
+"Language-Team: Italian (http://www.transifex.com/oca/OCA-web-8-0/language/it/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: it\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Anteprima dell'immagine"

+ 26 - 0
i18n/pt_BR.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# danimaribeiro <danimaribeiro@gmail.com>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-03-11 02:17+0000\n"
+"PO-Revision-Date: 2016-03-05 16:20+0000\n"
+"Last-Translator: danimaribeiro <danimaribeiro@gmail.com>\n"
+"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-web-8-0/language/pt_BR/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: pt_BR\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Preview da imagem"

+ 26 - 0
i18n/sl.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-11-23 13:46+0000\n"
+"PO-Revision-Date: 2015-11-19 06:03+0000\n"
+"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
+"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-web-8-0/language/sl/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: sl\n"
+"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Predogled slike"

+ 26 - 0
i18n/tr.po

@@ -0,0 +1,26 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * web_tree_image
+# 
+# Translators:
+# Ahmet Altınışık <aaltinisik@altinkaya.com.tr>, 2015
+msgid ""
+msgstr ""
+"Project-Id-Version: web (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-08 21:34+0000\n"
+"PO-Revision-Date: 2015-12-30 21:56+0000\n"
+"Last-Translator: Ahmet Altınışık <aaltinisik@altinkaya.com.tr>\n"
+"Language-Team: Turkish (http://www.transifex.com/oca/OCA-web-8-0/language/tr/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: tr\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#. module: web_tree_image
+#. openerp-web
+#: code:addons/web_tree_image/static/src/xml/widget.xml:31
+#, python-format
+msgid "Image preview"
+msgstr "Resim önizlemesi"

BIN
static/description/icon.png


+ 104 - 0
static/src/js/web_tree_image.js

@@ -0,0 +1,104 @@
+/*
+    OpenERP, Open Source Management Solution
+    This module copyright (C) 2014 Therp BV (<http://therp.nl>)
+                          (C) 2013 Marcel van der Boom <marcel@hsdev.com>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as
+    published by the Free Software Foundation, either version 3 of the
+    License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+openerp.web_tree_image = function(instance) {
+    "use strict";
+    var QWeb = instance.web.qweb;
+    instance.web.list.Image = instance.web.list.Column.extend({
+        format: function (row_data, options) {
+            /* Return a valid img tag. For image fields, test if the
+             field's value contains just the binary size and retrieve
+            the image from the dedicated controller in that case.
+            Otherwise, assume a character field containing either a
+            stock Odoo icon name without path or extension or a fully
+            fledged location or data url */
+            var self = this;
+
+            /*
+            Allow image to be displayed in 3 different ways:
+             - 'inline':    display image directly in tree view (default)
+             - 'icon':      display only an icon, show a full screen preview
+                            of the picture on click
+             - 'thumbnail': display image directly in tree view, show a
+                            full screen preview of the picture on click
+            */
+            self.display = self.display || 'inline';
+
+            if (!row_data[self.id] || !row_data[self.id].value) {
+                return '';
+            }
+            var value = row_data[self.id].value;
+            if (self.type === 'binary') {
+                if (value && value.substr(0, 10).indexOf(' ') === -1) {
+                    // The media subtype (png) seems to be arbitrary
+                    self.src = "data:image/png;base64," + value;
+                } else {
+                    var imageArgs = {
+                        model: options.model,
+                        field: self.id,
+                        id: options.id
+                    }
+                    if (self.resize) {
+                        imageArgs.resize = self.resize;
+                    }
+                    self.src = instance.session.url('/web/binary/image',
+                                                    imageArgs);
+                }
+            } else {
+                if (!/\//.test(row_data[self.id].value)) {
+                    self.src = '/web/static/src/img/icons/' +
+                               row_data[self.id].value + '.png';
+                } else {
+                    self.src = row_data[self.id].value;
+                }
+            }
+
+            if (self.display == 'icon' || self.display == 'thumbnail')
+            {
+                // use a unique id for the popup DOM node
+                var popupId = "o_web_tree_image_popup-" + row_data.id.value;
+                // use a unique id for the clickable DOM node
+                var clickableId = "o_web_tree_image_clickable-" +
+                                  row_data.id.value;
+
+                if (!$('#' + popupId).length)
+                {
+                    // add full screen preview to DOM
+                    $("body").append(QWeb.render("ListView.row.image.imageData",
+                                                 {widget: self,
+                                                  popupId: popupId}));
+                }
+
+                // defer execution until after this function has returned and
+                // DOM elements have been rendered
+                window.setTimeout(function() {
+                    // enable full screen preview on click on icon
+                        $("#" + clickableId).click(function() {
+                        $('#' + popupId).modal('show');
+                        return false;
+                    });
+                }, 0);
+            }
+
+            return QWeb.render('ListView.row.image',
+                               {widget: self, clickableId: clickableId});
+        },
+    });
+    instance.web.list.columns.add('field.image', 'instance.web.list.Image');
+};

+ 39 - 0
static/src/xml/widget.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template">
+    <t t-name="ListView.row.image"><!--
+        Inline display of the image.
+        --><img t-if="widget.display == 'inline'"
+                t-att-height="widget.height || 64"
+                t-att-src="widget.src" /><!--
+        Icon that can be clicked for a full screen preview of the image.
+        --><span t-if="widget.display == 'icon'"
+                 t-att-id="clickableId"
+                 class="fa fa-picture-o" /><!--
+        Thumbnail that can be clicked for a full screen preview of the image.
+        --><img t-if="widget.display == 'thumbnail'"
+                t-att-id="clickableId"
+                t-att-height="widget.height || 64"
+                t-att-src="widget.src" />
+    </t>
+
+    <!-- Use a separate template for the content of the full screen preview,
+         as it has to be inserted into the DOM separately, otherwise its
+         z-index is affected by parent elements and it does not appear
+         correctly in the foreground. -->
+    <div t-name="ListView.row.image.imageData" t-att-id="popupId"
+         class="modal" tabindex="-1">
+        <div class="modal-dialog">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal">
+                        x
+                    </button>
+                    <h4 class="modal-title">Image preview</h4>
+                </div>
+                <div class="modal-body">
+                    <img t-att-src="widget.src" class="img-responsive"/>
+                </div>
+            </div>
+        </div>
+    </div>
+</templates>

+ 10 - 0
view/assets.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <template id="assets_backend" name="tree icon assets" inherit_id="web.assets_backend">
+            <xpath expr="." position="inside">
+                <script type="text/javascript" src="/web_tree_image/static/src/js/web_tree_image.js"></script>
+            </xpath>
+        </template>
+    </data>
+</openerp>