mirror of https://github.com/OCA/web.git
Merge pull request #1006 from nikul-serpentcs/11-mig-web_tree_image
[11.0] [MIG] web_tree_imagepull/1043/head
commit
a5893f541c
|
@ -0,0 +1,59 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
: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 ``width`` attribute. Default width is 30px.
|
||||
|
||||
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
|
||||
=====
|
||||
|
||||
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 CSS ``max-height`` attribute,
|
||||
if you want to make the server return a resized, maybe to save data by making it
|
||||
return a smaller one or to have uniform images, use the
|
||||
``resize="<width>,<height>"`` attribute.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Stefan Rijnhart
|
||||
* Leonardo Donelli <donelli@webmonks.it>
|
||||
* Jay Vora <jay.vora@serpentcs.com>
|
||||
* Meet Dholakia <m.dholakia.serpentcs@gmail.com>
|
||||
* Nikul Chaudhary <nikul.chaudhary.serpentcs@gmail.com>
|
||||
|
||||
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.
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 Therp BV (<http://therp.nl>).
|
||||
# Copyright 2015 Leonardo Donelli @ MONKSoftware
|
||||
# Copyright 2013 Marcel van der Boom <marcel@hsdev.com>
|
||||
# Copyright 2016 - TODAY Serpent Consulting Services Pvt. Ltd.
|
||||
# (<http://www.serpentcs.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Show images in tree views',
|
||||
'version': '11.0.1.0.0',
|
||||
'author': "Therp BV, "
|
||||
"MONK Software, "
|
||||
"Odoo Community Association (OCA), "
|
||||
"Serpent Consulting Services Pvt. Ltd.",
|
||||
'website': 'https://github.com/OCA/Web',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Web',
|
||||
'depends': [
|
||||
'web',
|
||||
],
|
||||
'data': [
|
||||
'view/assets.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.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"
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
|
@ -0,0 +1,18 @@
|
|||
odoo.define('web_tree_image.web_tree_image', function(require) {
|
||||
"use strict";
|
||||
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
|
||||
ListRenderer.include({
|
||||
events: _.extend({}, ListRenderer.prototype.events, {
|
||||
'mouseover tbody tr td .o_field_image': '_onHoverRecord_img',
|
||||
}),
|
||||
_onHoverRecord_img: function (event) {
|
||||
var img_src = $(event.currentTarget).children('.img-responsive').attr('src')
|
||||
$(event.currentTarget).tooltip({
|
||||
title: "<img src="+img_src+" />",
|
||||
delay: 0,
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
.o_image_cell .o_field_image img{
|
||||
width:30px;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend" name="tree icon assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel='stylesheet' href='/web_tree_image/static/src/less/common.less'/>
|
||||
<script type="text/javascript" src="/web_tree_image/static/src/js/tooltip.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
Loading…
Reference in New Issue