forked from Techsystech/web
[IMP] web_tree_dynamic_colored_field: black, isort, prettier
parent
9994bc636b
commit
a9eb43b835
|
@ -0,0 +1 @@
|
||||||
|
../../../../web_tree_dynamic_colored_field
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
|
@ -13,12 +13,15 @@ odoo.define("web_tree_dynamic_colored_field", function (require) {
|
||||||
*/
|
*/
|
||||||
_renderBody: function () {
|
_renderBody: function () {
|
||||||
if (this.arch.attrs.colors) {
|
if (this.arch.attrs.colors) {
|
||||||
var colorAttr = this.arch.attrs.colors.split(';');
|
var colorAttr = this.arch.attrs.colors.split(";");
|
||||||
if (colorAttr.length > 0) {
|
if (colorAttr.length > 0) {
|
||||||
var colorType = colorAttr[0].split(':')[0].trim()
|
var colorType = colorAttr[0].split(":")[0].trim();
|
||||||
var colorField = colorAttr[0].split(':')[1].trim();
|
var colorField = colorAttr[0].split(":")[1].trim();
|
||||||
// validate the presence of that field in tree view
|
// 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
|
||||||
|
) {
|
||||||
if (colorType === "color_field") {
|
if (colorType === "color_field") {
|
||||||
this.colorField = colorField;
|
this.colorField = colorField;
|
||||||
} else if (colorType === "bg_color_field") {
|
} else if (colorType === "bg_color_field") {
|
||||||
|
@ -62,11 +65,15 @@ odoo.define("web_tree_dynamic_colored_field", function (require) {
|
||||||
}
|
}
|
||||||
var treeBgColor = record.data[this.bgColorField];
|
var treeBgColor = record.data[this.bgColorField];
|
||||||
if (treeBgColor) {
|
if (treeBgColor) {
|
||||||
$td.css('background-color', treeBgColor);
|
$td.css("background-color", treeBgColor);
|
||||||
|
}
|
||||||
|
// Apply <field>'s own `options`
|
||||||
|
if (!node.attrs.options) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (node.tag !== "field") {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// apply <field>'s own `options`
|
|
||||||
if (!node.attrs.options) { return; }
|
|
||||||
if (node.tag !== 'field') { return; }
|
|
||||||
var nodeOptions = node.attrs.options;
|
var nodeOptions = node.attrs.options;
|
||||||
if (!_.isObject(nodeOptions)) {
|
if (!_.isObject(nodeOptions)) {
|
||||||
nodeOptions = pyUtils.py_eval(nodeOptions);
|
nodeOptions = pyUtils.py_eval(nodeOptions);
|
||||||
|
|
Loading…
Reference in New Issue