From ebc1d24fc5767f670f67da98327f9fd5f8b2ef5b Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Tue, 17 Jan 2017 16:18:07 +0100 Subject: [PATCH] [FIX] web_calendar: set default color when not define in the calendar view --- .../static/src/js/web_calendar.js | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index 3a2f43e773f..cf44f7283e6 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -797,31 +797,32 @@ var CalendarView = View.extend({ self.now_filter_ids = []; var color_field = self.fields[self.color_field]; - _.each(events, function (e) { - var key,val = null; - if (color_field.type == "selection") { - key = e[self.color_field]; - val = _.find(color_field.selection, function(name){ return name[0] === key;}); - } else { - key = e[self.color_field][0]; - val = e[self.color_field]; - } - if (!self.all_filters[key]) { - filter_item = { - value: key, - label: val[1], - color: self.get_color(key), - avatar_model: (utils.toBoolElse(self.avatar_filter, true) ? self.avatar_filter : false ), - is_checked: true - }; - self.all_filters[key] = filter_item; - } - if (! _.contains(self.now_filter_ids, key)) { - self.now_filter_ids.push(key); - } - }); - - if (self.sidebar) { + if (color_field) { + _.each(events, function (e) { + var key,val = null; + if (color_field.type == "selection") { + key = e[self.color_field]; + val = _.find(color_field.selection, function(name){ return name[0] === key;}); + } else { + key = e[self.color_field][0]; + val = e[self.color_field]; + } + if (!self.all_filters[key]) { + filter_item = { + value: key, + label: val[1], + color: self.get_color(key), + avatar_model: (utils.toBoolElse(self.avatar_filter, true) ? self.avatar_filter : false ), + is_checked: true + }; + self.all_filters[key] = filter_item; + } + if (! _.contains(self.now_filter_ids, key)) { + self.now_filter_ids.push(key); + } + }); + } + if (self.sidebar && color_field) { self.sidebar.filter.render(); events = $.map(events, function (e) {