|
@ -8,6 +8,14 @@ openerp.web_tree_dynamic_colored_field = function(instance){ |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var get_eval_context = function(record){ |
|
|
|
|
|
return _.extend( |
|
|
|
|
|
{}, |
|
|
|
|
|
record.attributes, |
|
|
|
|
|
instance.web.pyeval.context() |
|
|
|
|
|
); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
var colorize_helper = function(obj, record, column, field_attribute, css_attribute){ |
|
|
var colorize_helper = function(obj, record, column, field_attribute, css_attribute){ |
|
|
var result = ''; |
|
|
var result = ''; |
|
|
if (column[field_attribute]){ |
|
|
if (column[field_attribute]){ |
|
@ -18,11 +26,7 @@ openerp.web_tree_dynamic_colored_field = function(instance){ |
|
|
var colors = colors.filter(function CheckUndefined(value, index, ar) { |
|
|
var colors = colors.filter(function CheckUndefined(value, index, ar) { |
|
|
return value != undefined; |
|
|
return value != undefined; |
|
|
}) |
|
|
}) |
|
|
var ctx = _.extend( |
|
|
|
|
|
{}, |
|
|
|
|
|
record.attributes, |
|
|
|
|
|
instance.web.pyeval.context() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
var ctx = get_eval_context(record); |
|
|
for(i=0, len=colors.length; i<len; ++i) { |
|
|
for(i=0, len=colors.length; i<len; ++i) { |
|
|
pair = colors[i]; |
|
|
pair = colors[i]; |
|
|
var color = pair[0]; |
|
|
var color = pair[0]; |
|
@ -48,4 +52,24 @@ openerp.web_tree_dynamic_colored_field = function(instance){ |
|
|
this.columns.fct_colorize = colorize; |
|
|
this.columns.fct_colorize = colorize; |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
instance.web.ListView.include({ |
|
|
|
|
|
style_for: function (record) |
|
|
|
|
|
{ |
|
|
|
|
|
var result = this._super.apply(this, arguments); |
|
|
|
|
|
if(this.fields_view.arch.attrs.color_field) |
|
|
|
|
|
{ |
|
|
|
|
|
var color = py.evaluate( |
|
|
|
|
|
py.parse(py.tokenize( |
|
|
|
|
|
this.fields_view.arch.attrs.color_field |
|
|
|
|
|
)), |
|
|
|
|
|
get_eval_context(record)).toJSON(); |
|
|
|
|
|
if(color) |
|
|
|
|
|
{ |
|
|
|
|
|
result += 'color: ' + color; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
} |
|
|
} |