mirror of https://github.com/OCA/web.git
[MIG] web_tree_dynamic_colored_field: Migration to 13.0
Use 'options' instead of 'colors' on tree views
The colors attribute has been removed from the RelaxNG schema in
Odoo [0], so use the 'options' instead.
Closes #1479
[0] 7024f8d58b (diff-e9acd2f731cc01f302055b6e232df983)
pull/1817/head
parent
da9798d819
commit
0cb325f1f8
|
@ -4,7 +4,7 @@
|
||||||
"name": "Colorize field in tree views",
|
"name": "Colorize field in tree views",
|
||||||
"summary": "Allows you to dynamically color fields on tree views",
|
"summary": "Allows you to dynamically color fields on tree views",
|
||||||
"category": "Hidden/Dependency",
|
"category": "Hidden/Dependency",
|
||||||
"version": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"depends": ["web"],
|
"depends": ["web"],
|
||||||
"author": "Camptocamp, Therp BV, Odoo Community Association (OCA)",
|
"author": "Camptocamp, Therp BV, Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<field name="inherit_id" ref="base.view_users_tree" />
|
<field name="inherit_id" ref="base.view_users_tree" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="colors">color_field: lang</attribute>
|
<attribute name="options">{"color_field": "lang"}</attribute>
|
||||||
</tree>
|
</tree>
|
||||||
<field name="login_date" position="attributes">
|
<field name="login_date" position="attributes">
|
||||||
<attribute name="options">{
|
<attribute name="options">{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
This module aims to add support for dynamically coloring fields in tree view
|
This module aims to add support for dynamically coloring fields in tree view
|
||||||
according to data in the record.
|
according to data in the record.
|
||||||
|
|
||||||
It provides attributes on fields with the similar syntax as the ``colors`` attribute
|
It provides attributes on fields with a similar syntax as the ``colors`` attribute
|
||||||
in tree tags.
|
in tree tags.
|
||||||
|
|
||||||
Further, it provides a ``color_field`` attribute on tree tags's ``colors`` to use
|
Further, it provides a ``color_field`` attribute on tree tags's ``options`` to use
|
||||||
a field's value as color.
|
a field's value as color.
|
||||||
|
|
||||||
Features
|
Features
|
||||||
|
@ -12,4 +12,4 @@ Features
|
||||||
|
|
||||||
* Add attribute ``bg_color`` on field's ``options`` to color background of a cell in tree view
|
* Add attribute ``bg_color`` on field's ``options`` to color background of a cell in tree view
|
||||||
* Add attribute ``fg_color`` on field's ``options`` to change text color of a cell in tree view
|
* Add attribute ``fg_color`` on field's ``options`` to change text color of a cell in tree view
|
||||||
* Add attribute ``color_field`` on the tree element's ``colors`` to use as color
|
* Add attribute ``color_field`` on the tree element's ``options`` to use as color
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
|
|
||||||
With this example, column which renders 'name' field will have its text colored in white on a customer records.
|
With this example, column which renders 'name' field will have its text colored in white on a customer records.
|
||||||
|
|
||||||
* In the tree view declaration, use ``options='"color_field": "my_color"'`` attribute in the ``tree`` tag::
|
* In the tree view declaration, use ``options='{"color_field": "my_color"}'`` attribute in the ``tree`` tag::
|
||||||
|
|
||||||
...
|
...
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="View name" colors="color_field: my_color" >
|
<tree string="View name" options='{"color_field": "my_color"}' >
|
||||||
...
|
...
|
||||||
<field name="my_color" invisible="1"/>
|
<field name="my_color" invisible="1"/>
|
||||||
...
|
...
|
||||||
|
|
|
@ -11,11 +11,14 @@ odoo.define('web_tree_dynamic_colored_field', function (require) {
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_renderBody: function () {
|
_renderBody: function () {
|
||||||
if (this.arch.attrs.colors) {
|
if (this.arch.attrs.options) {
|
||||||
var colorAttr = this.arch.attrs.colors.split(';');
|
var archOptions = this.arch.attrs.options;
|
||||||
if (colorAttr.length > 0) {
|
if (!_.isObject(archOptions)) {
|
||||||
var colorField = colorAttr[0].split(':')[1].trim();
|
archOptions = pyUtils.py_eval(archOptions);
|
||||||
// validate the presence of that field in tree view
|
}
|
||||||
|
var colorField = archOptions.color_field;
|
||||||
|
if (colorField) {
|
||||||
|
// Validate the presence of that field in tree view
|
||||||
if (this.state.data.length && colorField in this.state.data[0].data) {
|
if (this.state.data.length && colorField in this.state.data[0].data) {
|
||||||
this.colorField = colorField;
|
this.colorField = colorField;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue