From 79fd6b76de4eb6e5f72b08d5ddd70d312748ad81 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Thu, 7 May 2015 13:57:33 +0200 Subject: [PATCH] [IMP][web_widget_auto_color] Use render value to allow to use this widget on all type of field --- web_widget_auto_color/static/src/js/view_list.js | 10 +++------- web_widget_auto_color/static/src/xml/templates.xml | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/web_widget_auto_color/static/src/js/view_list.js b/web_widget_auto_color/static/src/js/view_list.js index c17ac237..a5e16cfe 100644 --- a/web_widget_auto_color/static/src/js/view_list.js +++ b/web_widget_auto_color/static/src/js/view_list.js @@ -43,10 +43,9 @@ openerp.web_widget_auto_color = function(instance) { return sum }, - auto_color_cell_style: function(record, column){ + auto_color_cell_style: function(value){ style = '' - value = record.get(column.name) - if (value != false && value != undefined) { + if (value != "" && value != undefined) { var intValue = this.getIntValue(value) bgcolor = this.get_seed_random_color(intValue) fontcolor = this.inverse_color(bgcolor) @@ -57,9 +56,6 @@ openerp.web_widget_auto_color = function(instance) { }); - instance.web.form.widgets.add('autocolor', 'instance.web.form.FieldAutoColor'); - - instance.web.form.FieldAutoColor = instance.web.form.FieldChar.extend({ - }); + instance.web.form.widgets.add('autocolor', 'instance.web.form.AbstractField'); }; \ No newline at end of file diff --git a/web_widget_auto_color/static/src/xml/templates.xml b/web_widget_auto_color/static/src/xml/templates.xml index 3f1c488c..c98bbe6b 100644 --- a/web_widget_auto_color/static/src/xml/templates.xml +++ b/web_widget_auto_color/static/src/xml/templates.xml @@ -2,7 +2,7 @@ - this.attr('t-att-style', "column.widget =='autocolor' and view.auto_color_cell_style(record, column)") + this.attr('t-att-style', "column.widget =='autocolor' and view.auto_color_cell_style(render_cell(record, column))")