diff --git a/addons/web/static/src/js/framework/core.js b/addons/web/static/src/js/framework/core.js index 4d6d91d907b..9e2dfd964d0 100644 --- a/addons/web/static/src/js/framework/core.js +++ b/addons/web/static/src/js/framework/core.js @@ -37,17 +37,6 @@ _.each('resize,scroll'.split(','), function(evtype) { }); }); - -// Underscore customization -//------------------------------------------------------------------------- -_.str.toBoolElse = function (str, elseValues, trueValues, falseValues) { - var ret = _.str.toBool(str, trueValues, falseValues); - if (_.isUndefined(ret)) { - return elseValues; - } - return ret; -}; - // IE patch //------------------------------------------------------------------------- if (typeof(console) === "undefined") { diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js index 40774e9095d..edf7355dc29 100644 --- a/addons/web/static/src/js/framework/utils.js +++ b/addons/web/static/src/js/framework/utils.js @@ -462,6 +462,15 @@ function swap(array, elem1, elem2) { array[i1] = elem2; } +function toBoolElse (str, elseValues, trueValues, falseValues) { + var ret = _.str.toBool(str, trueValues, falseValues); + if (_.isUndefined(ret)) { + return elseValues; + } + return ret; +} + + return { divmod: divmod, modf: modf, @@ -491,6 +500,7 @@ return { reject_after: reject_after, delay: delay, swap: swap, + toBoolElse: toBoolElse, }; }); diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index 73abe402dab..e907f09ffd8 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -10,6 +10,7 @@ var form_common = require('web.form_common'); var formats = require('web.formats'); var Model = require('web.DataModel'); var time = require('web.time'); +var utils = require('web.utils'); var View = require('web.View'); var widgets = require('web_calendar.widgets'); var local_storage = require('web.local_storage'); @@ -138,14 +139,14 @@ var CalendarView = View.extend({ //if quick_add = not specified in view, we use the default quick_create_instance //if quick_add = is NOT False and IS specified in view, we this one for quick_create_instance' - this.quick_add_pop = (isNullOrUndef(attrs.quick_add) || _.str.toBoolElse(attrs.quick_add, true)); + this.quick_add_pop = (isNullOrUndef(attrs.quick_add) || utils.toBoolElse(attrs.quick_add, true)); // The display format which will be used to display the event where fields are between "[" and "]" if (!isNullOrUndef(attrs.display)) { this.how_display_event = attrs.display; // String with [FIELD] } // If this field is set ot true, we don't open the event in form view, but in a popup with the view_id passed by this parameter - if (isNullOrUndef(attrs.event_open_popup) || !_.str.toBoolElse(attrs.event_open_popup, true)) { + if (isNullOrUndef(attrs.event_open_popup) || !utils.toBoolElse(attrs.event_open_popup, true)) { this.open_popup_action = false; } else { this.open_popup_action = attrs.event_open_popup; @@ -155,7 +156,7 @@ var CalendarView = View.extend({ // If this field is set ot true, we don't add itself as an attendee when we use attendee_people to add each attendee icon on an event // The color is the color of the attendee, so don't need to show again that it will be present - this.colorIsAttendee = !(isNullOrUndef(attrs.color_is_attendee) || !_.str.toBoolElse(attrs.color_is_attendee, true)); + this.colorIsAttendee = !(isNullOrUndef(attrs.color_is_attendee) || !utils.toBoolElse(attrs.color_is_attendee, true)); // if we have not sidebar, (eg: Dashboard), we don't use the filter "coworkers" if (isNullOrUndef(this.options.sidebar)) { @@ -807,7 +808,7 @@ var CalendarView = View.extend({ value: key, label: val[1], color: self.get_color(key), - avatar_model: (_.str.toBoolElse(self.avatar_filter, true) ? self.avatar_filter : false ), + avatar_model: (utils.toBoolElse(self.avatar_filter, true) ? self.avatar_filter : false ), is_checked: true }; self.all_filters[key] = filter_item;