Browse Source

Merge e8b721cc36 into d736ee4460

pull/839/merge
Florent de Labarre 5 years ago
committed by GitHub
parent
commit
1b23ffcf80
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      setup/web_tree_dynamic_colored_line/odoo/addons/web_tree_dynamic_colored_line
  2. 2
      setup/web_tree_dynamic_colored_line/setup.cfg
  3. 6
      setup/web_tree_dynamic_colored_line/setup.py
  4. 70
      web_tree_dynamic_colored_line/README.rst
  5. 1
      web_tree_dynamic_colored_line/__init__.py
  6. 14
      web_tree_dynamic_colored_line/__manifest__.py
  7. 12
      web_tree_dynamic_colored_line/demo/res_partner.xml
  8. BIN
      web_tree_dynamic_colored_line/static/description/icon.png
  9. 41
      web_tree_dynamic_colored_line/static/src/js/list_view.js
  10. 10
      web_tree_dynamic_colored_line/views/web_tree_dynamic_colored_line.xml

1
setup/web_tree_dynamic_colored_line/odoo/addons/web_tree_dynamic_colored_line

@ -0,0 +1 @@
../../../../web_tree_dynamic_colored_line

2
setup/web_tree_dynamic_colored_line/setup.cfg

@ -0,0 +1,2 @@
[bdist_wheel]
universal=1

6
setup/web_tree_dynamic_colored_line/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

70
web_tree_dynamic_colored_line/README.rst

@ -0,0 +1,70 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
===========================
Colorize line in tree views
===========================
This module extends the functionality of decorator-xx, in tree view. In Odoo V11, the attribute colors is not supported.
Usage
=====
Exemple
-------
<tree string="Stock Move" colors="blue:tetris == 'blue';red:tetris == 'red'">
<field name="tetris"/>
</tree>
Color codage
------------
* css standard name: red
* hexadecidmal: #CF403E
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/web/162/11.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/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
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* Florent de Labarre <florent.mirieu@gmail.com>
Do not contact contributors directly about support or help with technical issues.
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.

1
web_tree_dynamic_colored_line/__init__.py

@ -0,0 +1 @@

14
web_tree_dynamic_colored_line/__manifest__.py

@ -0,0 +1,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Colorize line in tree views",
'summary': "Allows you to dynamically color fields on tree views",
'author': "Odoo Community Association (OCA), Florent de Labarre",
'category': 'Web',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/web',
'version': '11.0.1.0.0',
'depends': ['web'],
'data': ['views/web_tree_dynamic_colored_line.xml'],
'demo': ['demo/res_partner.xml'],
'installable': True,
}

12
web_tree_dynamic_colored_line/demo/res_partner.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_partner_tree" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="colors">colors: red:phone == False;</attribute>
</tree>
</field>
</record>
</odoo>

BIN
web_tree_dynamic_colored_line/static/description/icon.png

After

Width: 200  |  Height: 200  |  Size: 4.6 KiB

41
web_tree_dynamic_colored_line/static/src/js/list_view.js

@ -0,0 +1,41 @@
// Copyright 2018 Florent de Labarre
odoo.define("web_tree_dynamic_colored_line.ListView", function(require) {
"use strict";
var ListRenderer = require('web.ListRenderer');
ListRenderer.include({
init: function() {
this._super.apply(this, arguments);
if (this.arch.attrs.colors) {
this.colors = _(this.arch.attrs.colors.split(';')).chain()
.compact()
.map(function(color_pair) {
var pair = color_pair.split(':'),
color = pair[0],
expr = pair[1];
return [color, py.parse(py.tokenize(expr))];
}).value();
}
},
_renderRow: function(record) {
var $tr = this._super.apply(this, arguments);
this._setColorClasses(record, $tr);
return $tr;
},
_setColorClasses: function(record, $tr) {
_.each(this.colors, function(colors) {
if (py.PY_isTrue(py.evaluate(colors[1], record.evalContext))) {
$tr.css({
'color': colors[0]
});
}
});
},
});
});

10
web_tree_dynamic_colored_line/views/web_tree_dynamic_colored_line.xml

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>
<data>
<template id="assets_backend" name="module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_tree_dynamic_colored_line/static/src/js/list_view.js"></script>
</xpath>
</template>
</data>
</odoo>
Loading…
Cancel
Save