diff --git a/.bzrignore b/.bzrignore index e7618c7b0ce..86a1881981f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,21 +1,15 @@ -.*.swp -.bzrignore -.idea -.project -.pydevproject -.ropeproject -.settings -.DS_Store -openerp/addons/* -openerp/filestore* -.Python -*.pyc -*.pyo -bin/* +.* +*.egg-info +*.orig +*.vim build/ -include/ -lib/ -share/ -doc/_build/* -win32/*.bat -win32/meta.py +RE:^bin/ +RE:^dist/ +RE:^include/ + +RE:^share/ +RE:^man/ +RE:^lib/ + +RE:^addons/\w+/doc/_build/ +RE:^.*?/node_modules diff --git a/addons/web/Gruntfile.js b/addons/web/Gruntfile.js new file mode 100644 index 00000000000..6561aecd3bd --- /dev/null +++ b/addons/web/Gruntfile.js @@ -0,0 +1,22 @@ +module.exports = function(grunt) { + + grunt.initConfig({ + jshint: { + files: ['static/src/**/*.js'], + options: { + sub: true, //[] instead of . + asi: true, //semicolons + evil: true, //eval + laxbreak: true, //unsafe line breaks + loopfunc: true, // functions in loops + }, + } + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + + grunt.registerTask('test', ['jshint']); + + grunt.registerTask('default', ['jshint']); + +}; \ No newline at end of file diff --git a/addons/web/package.json b/addons/web/package.json new file mode 100644 index 00000000000..f8dfc2879d6 --- /dev/null +++ b/addons/web/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.6.0" + } +} \ No newline at end of file diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 89c44a9b7ed..5ecfb5a9943 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1108,7 +1108,7 @@ instance.web.Menu = instance.web.Widget.extend({ add_menu_ids(menu); }); } - }; + } add_menu_ids(menu); self.do_load_needaction(menu_ids).then(function () { self.trigger("need_action_reloaded"); diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 58c2969bb20..a8846018e3e 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -73,7 +73,7 @@ openerp.web.corelib = function(instance) { */ (function() { var initializing = false, - fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; + fnTest = /xyz/.test(function(){xyz();}) ? /\b_super\b/ : /.*/; // The web Class implementation (does nothing) instance.web.Class = function(){}; @@ -123,7 +123,6 @@ openerp.web.corelib = function(instance) { function Class() { if(this.constructor !== instance.web.Class){ throw new Error("You can only instanciate objects with the 'new' operator"); - return null; } // All construction is actually done in the init method if (!initializing && this.init) { @@ -297,7 +296,7 @@ var Events = instance.web.Class.extend({ var ev; events = events.split(/\s+/); var calls = this._callbacks || (this._callbacks = {}); - while (ev = events.shift()) { + while ((ev = events.shift())) { var list = calls[ev] || (calls[ev] = {}); var tail = list.tail || (list.tail = list.next = {}); tail.callback = callback; @@ -311,9 +310,9 @@ var Events = instance.web.Class.extend({ var ev, calls, node; if (!events) { delete this._callbacks; - } else if (calls = this._callbacks) { + } else if ((calls = this._callbacks)) { events = events.split(/\s+/); - while (ev = events.shift()) { + while ((ev = events.shift())) { node = calls[ev]; delete calls[ev]; if (!callback || !node) @@ -347,7 +346,7 @@ var Events = instance.web.Class.extend({ all = calls['all']; (events = events.split(/\s+/)).push(null); // Save references to the current heads & tails. - while (event = events.shift()) { + while ((event = events.shift())) { if (all) events.push({ next : all.next, @@ -362,7 +361,7 @@ var Events = instance.web.Class.extend({ }); } rest = Array.prototype.slice.call(arguments, 1); - while (node = events.pop()) { + while ((node = events.pop())) { tail = node.tail; args = node.event ? [ node.event ].concat(rest) : rest; while ((node = node.next) !== tail) { @@ -692,11 +691,6 @@ instance.web.Widget = instance.web.Controller.extend({ insertion(target); return this.start(); }, - /** - * This is the method to implement to render the Widget. - */ - renderElement: function() { - }, /** * Method called after rendering. Mostly used to bind actions, perform asynchronous * calls, etc... @@ -966,7 +960,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { init: function() { instance.web.PropertiesMixin.init.call(this); this.server = null; - this.debug = ($.deparam($.param.querystring()).debug != undefined); + this.debug = ($.deparam($.param.querystring()).debug !== undefined); this.override_session = false; this.session_id = undefined; }, diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index c9c6f82a98d..b3adea81a60 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -250,7 +250,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess continue; instance[mod] = {}; // init module mod - if(instance._openerp[mod] != undefined) { + if(instance._openerp[mod] !== undefined) { instance._openerp[mod](instance,instance[mod]); this.module_loaded[mod] = true; } @@ -585,7 +585,7 @@ instance.web.qweb.preprocess_node = function() { case Node.ELEMENT_NODE: // Element var attr, attrs = ['label', 'title', 'alt', 'placeholder']; - while (attr = attrs.pop()) { + while ((attr = attrs.pop())) { if (this.attributes[attr]) { this.attributes[attr] = instance.web._t(this.attributes[attr]); } diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 679afe77bcd..79ec160eb70 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -100,7 +100,7 @@ instance.web.Query = instance.web.Class.extend({ * @returns {jQuery.Deferred} */ count: function () { - if (this._count != undefined) { return $.when(this._count); } + if (this._count !== undefined) { return $.when(this._count); } return this._model.call( 'search_count', [this._filter], { context: this._model.context(this._context)}); @@ -747,7 +747,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ }); }, size: function () { - if (this._length != null) { + if (this._length !== null) { return this._length; } return this._super(); diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js index fb5e391effd..7a390d0819f 100644 --- a/addons/web/static/src/js/data_export.js +++ b/addons/web/static/src/js/data_export.js @@ -93,7 +93,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ self.$el.find('#fields_list option').remove(); var export_id = self.$el.find('#saved_export_list option:selected').val(); if (export_id) { - self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).done(self.do_load_export_field); + self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id, 10)}).done(self.do_load_export_field); } }); self.$el.find('#delete_export_list').click(function() { @@ -215,7 +215,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ self.$el.find("tr[id='treerow-" + record.id + "']").click(function(e) { if (e.shiftKey) { var frst_click, scnd_click = ''; - if (self.row_index == 0) { + if (self.row_index === 0) { self.row_index = this.rowIndex; frst_click = self.$el.find("tr[id^='treerow-']")[self.row_index-1]; $(frst_click).addClass("ui-selected"); diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 851b60af229..f4df990675c 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -141,6 +141,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { return ''; } console.warn('Field', descriptor, 'had an empty string as value, treating as false...'); + return value_if_empty === undefined ? '' : value_if_empty; case false: case Infinity: case -Infinity: @@ -219,9 +220,9 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) { case "": return value_if_empty === undefined ? false : value_if_empty; } + var tmp; switch (descriptor.widget || descriptor.type || (descriptor.field && descriptor.field.type)) { case 'integer': - var tmp; do { tmp = value; value = value.replace(instance.web._t.database.parameters.thousands_sep, ""); @@ -231,7 +232,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) { throw new Error(_.str.sprintf(_t("'%s' is not a correct integer"), value)); return tmp; case 'float': - var tmp = Number(value); + tmp = Number(value); if (!isNaN(tmp)) return tmp; @@ -314,4 +315,34 @@ instance.web.auto_date_to_str = function(value, type) { } }; +/** + * performs a half up rounding with arbitrary precision, correcting for float loss of precision + * See the corresponding float_round() in server/tools/float_utils.py for more info + * @param {Number} the value to be rounded + * @param {Number} a non zero precision parameter. eg: 0.01 rounds to two digits. + */ +instance.web.round_precision = function(value, precision){ + if(!value){ + return 0; + }else if(!precision){ + throw new Error('round_precision(...): Cannot round value: '+value+' with a precision of zero (or undefined)'); + } + var normalized_value = value / precision; + var epsilon_magnitude = Math.log(Math.abs(normalized_value))/Math.log(2); + var epsilon = Math.pow(2, epsilon_magnitude - 53); + normalized_value += normalized_value >= 0 ? epsilon : -epsilon; + var rounded_value = Math.round(normalized_value); + return rounded_value * precision; +}; + +/** + * performs a half up rounding with a fixed amount of decimals, correcting for float loss of precision + * See the corresponding float_round() in server/tools/float_utils.py for more info + * @param {Number} the value to be rounded + * @param {Number} the number of decimals. eg: round_decimals(3.141592,2) -> 3.14 + */ +instance.web.round_decimals = function(value, decimals){ + return instance.web.round_precision(value, Math.pow(10,-decimals)); +}; + }; diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js index 6ce85f8d4a3..02d828001c0 100644 --- a/addons/web/static/src/js/pyeval.js +++ b/addons/web/static/src/js/pyeval.js @@ -795,11 +795,18 @@ openerp.web.pyeval = function (instance) { //noinspection FallthroughInSwitchStatementJS switch(type) { - case 'context': object = [object]; - case 'contexts': return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context); - case 'domain': object = [object]; - case 'domains': return eval_domains(object, context); - case 'groupbys': return eval_groupbys(object, context); + case 'context': + case 'contexts': + if (type === 'context') + object = [object]; + return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context); + case 'domain': + case 'domains': + if (type === 'domain') + object = [object]; + return eval_domains(object, context); + case 'groupbys': + return eval_groupbys(object, context); } throw new Error("Unknow evaluation type " + type) }; diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 5d06d75573f..12e1c2bc0ec 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -65,7 +65,7 @@ my.SearchQuery = B.Collection.extend({ }, this); }, add: function (values, options) { - options || (options = {}); + options = options || {}; if (!(values instanceof Array)) { values = [values]; } @@ -85,7 +85,7 @@ my.SearchQuery = B.Collection.extend({ return this; }, toggle: function (value, options) { - options || (options = {}); + options = options || {}; var facet = this.detect(function (facet) { return facet.get('category') === value.category @@ -1107,7 +1107,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in if (!contexts.length) { return; } if (contexts.length === 1) { return contexts[0]; } - return _.extend(new instance.web.CompoundContext, { + return _.extend(new instance.web.CompoundContext(), { __contexts: contexts }); }, @@ -1276,7 +1276,7 @@ instance.web.search.Field = instance.web.search.Input.extend( /** @lends instanc if (contexts.length === 1) { return contexts[0]; } - return _.extend(new instance.web.CompoundContext, { + return _.extend(new instance.web.CompoundContext(), { __contexts: contexts }); }, @@ -1321,7 +1321,7 @@ instance.web.search.Field = instance.web.search.Input.extend( /** @lends instanc domains.unshift(['|']); } - return _.extend(new instance.web.CompoundDomain, { + return _.extend(new instance.web.CompoundDomain(), { __domains: domains }); } @@ -1919,7 +1919,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @ }, changed: function() { var nval = this.$(".searchview_extended_prop_field").val(); - if(this.attrs.selected == null || nval != this.attrs.selected.name) { + if(this.attrs.selected === null || this.attrs.selected === undefined || nval != this.attrs.selected.name) { this.select_field(_.detect(this.fields, function(x) {return x.name == nval;})); } }, @@ -1941,13 +1941,13 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @ */ select_field: function(field) { var self = this; - if(this.attrs.selected != null) { + if(this.attrs.selected !== null && this.attrs.selected !== undefined) { this.value.destroy(); this.value = null; this.$('.searchview_extended_prop_op').html(''); } this.attrs.selected = field; - if(field == null) { + if(field === null || field === undefined) { return; } @@ -1967,7 +1967,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @ }, get_proposition: function() { - if ( this.attrs.selected == null) + if (this.attrs.selected === null || this.attrs.selected === undefined) return null; var field = this.attrs.selected; var op_select = this.$('.searchview_extended_prop_op')[0]; @@ -2097,7 +2097,7 @@ instance.web.search.ExtendedSearchProposition.Integer = instance.web.search.Exte get_value: function() { try { var val =this.$el.val(); - return instance.web.parse_value(val == "" ? 0 : val, {'widget': 'integer'}); + return instance.web.parse_value(val === "" ? 0 : val, {'widget': 'integer'}); } catch (e) { return ""; } @@ -2124,7 +2124,7 @@ instance.web.search.ExtendedSearchProposition.Float = instance.web.search.Extend get_value: function() { try { var val =this.$el.val(); - return instance.web.parse_value(val == "" ? 0.0 : val, {'widget': 'float'}); + return instance.web.parse_value(val === "" ? 0.0 : val, {'widget': 'float'}); } catch (e) { return ""; } diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d2f55c0901e..0f33de0814e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -346,7 +346,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.on_form_changed(); self.rendering_engine.init_fields(); self.is_initialized.resolve(); - self.do_update_pager(record.id == null); + self.do_update_pager(record.id === null || record.id === undefined); if (self.sidebar) { self.sidebar.do_attachement_update(self.dataset, self.datarecord.id); } @@ -465,7 +465,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM // form field if (self.fields[field]) { var value_ = self.fields[field].get_value(); - return value_ == null ? false : value_; + return value_ === null || value_ === undefined ? false : value_; } // parent field var splitted = field.split('.'); @@ -475,7 +475,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } var p_val = parent_fields[_.str.trim(splitted[1])]; if (p_val !== undefined) { - return p_val == null ? false : p_val; + return p_val === null || p_val === undefined ? false : p_val; } } // string literal @@ -621,7 +621,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } return $.when(); }); - }; + } return iterate(); }); }, @@ -943,11 +943,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM reload: function() { var self = this; return this.reload_mutex.exec(function() { - if (self.dataset.index == null) { + if (self.dataset.index === null || self.dataset.index === undefined) { self.trigger("previous_view"); return $.Deferred().reject().promise(); } - if (self.dataset.index == null || self.dataset.index < 0) { + if (self.dataset.index < 0) { return $.when(self.on_button_new()); } else { var fields = _.keys(self.fields_view.fields); @@ -1714,7 +1714,7 @@ instance.web.form.compute_domain = function(expr, fields) { }; instance.web.form.is_bin_size = function(v) { - return /^\d+(\.\d*)? \w+$/.test(v); + return (/^\d+(\.\d*)? \w+$/).test(v); }; /** @@ -2642,7 +2642,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we if (! this.get("effective_readonly")) { var show_value = instance.web.format_value(this.get('value'), this, ''); if (show_value === '') { - this.$textarea.css('height', parseInt(this.default_height)+"px"); + this.$textarea.css('height', parseInt(this.default_height, 10)+"px"); } this.$textarea.val(show_value); if (! this.auto_sized) { @@ -3265,7 +3265,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc this.$input.keydown(input_changed); this.$input.change(input_changed); this.$drop_down.click(function() { - self.$input.focus(); + self.$input.focus(); if (self.$input.autocomplete("widget").is(":visible")) { self.$input.autocomplete("close"); } else { @@ -3740,7 +3740,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ }, reload_current_view: function() { var self = this; - return self.is_loaded = self.is_loaded.then(function() { + self.is_loaded = self.is_loaded.then(function() { var active_view = self.viewmanager.active_view; var view = self.viewmanager.views[active_view].controller; if(active_view === "list") { @@ -3758,13 +3758,15 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ return view.do_search(self.build_domain(), self.dataset.get_context(), []); } }, undefined); + return self.is_loaded; }, set_value: function(value_) { value_ = value_ || []; var self = this; this.dataset.reset_ids([]); + var ids; if(value_.length >= 1 && value_[0] instanceof Array) { - var ids = []; + ids = []; _.each(value_, function(command) { var obj = {values: command[2]}; switch (command[0]) { @@ -3795,7 +3797,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ this._super(ids); this.dataset.set_ids(ids); } else if (value_.length >= 1 && typeof(value_[0]) === "object") { - var ids = []; + ids = []; this.dataset.delete_all = true; _.each(value_, function(command) { var obj = {values: command}; @@ -3850,7 +3852,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ this.viewmanager.views[this.viewmanager.active_view].controller) { var view = this.viewmanager.views[this.viewmanager.active_view].controller; if (this.viewmanager.active_view === "form") { - if (!view.is_initialized.state() === 'resolved') { + if (view.is_initialized.state() !== 'resolved') { return $.when(false); } return $.when(view.save()); @@ -3870,7 +3872,6 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ .invoke('is_valid') .all(_.identity) .value(); - break; case 'list': return view.is_valid(); } @@ -4256,7 +4257,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in }, core: { onSetInputData: function(e, data) { - if (data == '') { + if (data === '') { this._plugins.autocomplete._suggestions = null; } this.input().val(data); @@ -4578,8 +4579,9 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( if (type !== "form") return; var self = this; + var pop; if (this.dataset.index === null) { - var pop = new instance.web.form.SelectCreatePopup(this); + pop = new instance.web.form.SelectCreatePopup(this); pop.select_element( this.field.relation, { @@ -4599,7 +4601,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend( }); } else { var id = self.dataset.ids[self.dataset.index]; - var pop = new instance.web.form.FormOpenPopup(this); + pop = new instance.web.form.FormOpenPopup(this); pop.show_element(self.field.relation, id, self.build_context(), { title: _t("Open: ") + self.string, write_function: function(id, data, options) { @@ -4935,7 +4937,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend self.select_elements(self.selected_ids); self.destroy(); }); - var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create"); + $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create"); $cbutton.click(function() { self.new_object(); }); @@ -5190,18 +5192,18 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({ } }, render_value: function() { + var show_value; if (!this.get("effective_readonly")) { - var show_value; if (this.node.attrs.filename) { show_value = this.view.datarecord[this.node.attrs.filename] || ''; } else { - show_value = (this.get('value') != null && this.get('value') !== false) ? this.get('value') : ''; + show_value = (this.get('value') !== null && this.get('value') !== undefined && this.get('value') !== false) ? this.get('value') : ''; } this.$el.find('input').eq(0).val(show_value); } else { this.$el.find('a').toggle(!!this.get('value')); if (this.get('value')) { - var show_value = _t("Download") + show_value = _t("Download") if (this.view) show_value += " " + (this.view.datarecord[this.node.attrs.filename] || ''); this.$el.find('a').text(show_value); @@ -5553,11 +5555,12 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ on_click_stage: function (ev) { var self = this; var $li = $(ev.currentTarget); + var val; if (this.field.type == "many2one") { - var val = parseInt($li.data("id")); + val = parseInt($li.data("id"), 10); } else { - var val = $li.data("id"); + val = $li.data("id"); } if (val != self.get('value')) { this.view.recursive_save().done(function() { diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 4f58b002328..991f4db6852 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -171,11 +171,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi current_date: new Date().toString('yyyy-MM-dd') // TODO: time, datetime, relativedelta }); - + var i; + var pair; + var expression; if (this.fonts) { - for(var i=0, len=this.fonts.length; i= self.records.length) { self.dataset.index = 0; } @@ -1517,7 +1519,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we // if drag to 1st row (to = 0), start sequencing from 0 // (exclusive lower bound) seq = to ? list.records.at(to - 1).get(seqname) : 0; - while (++seq, record = list.records.at(index++)) { + while (++seq, (record = list.records.at(index++))) { // write are independent from one another, so we can just // launch them all at the same time and we don't really // give a fig about when they're done @@ -1825,7 +1827,7 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ var instance_ = (records[i] instanceof Record) ? records[i] : new Record(records[i]); instance_.bind(null, this._onRecordEvent); this._byId[instance_.get('id')] = instance_; - if (options.at == undefined) { + if (options.at === undefined || options.at === null) { this.records.push(instance_); if (!options.silent) { this.trigger('add', this, instance_, this.records.length-1); @@ -1867,7 +1869,8 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ if (!_(this._proxies).isEmpty()) { var record = null; _(this._proxies).detect(function (proxy) { - return record = proxy.get(id); + record = proxy.get(id); + return record; }); return record; } @@ -1881,10 +1884,11 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ * @returns {Collection} */ proxy: function (section) { - return this._proxies[section] = new Collection(null, { + this._proxies[section] = new Collection(null, { parent: this, key: section }).bind(null, this._onRecordEvent); + return this._proxies[section]; }, /** * @param {Array} [records] diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 512fc4ff373..1a06720a274 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -515,10 +515,6 @@ openerp.web.list_editable = function (instance) { }; } else if (document.body.createTextRange) { throw new Error("Implement text range handling for MSIE"); - var sel = document.body.createTextRange(); - if (sel.parentElement() === el) { - - } } // Element without selection ranges (select, div/@contenteditable) return null; @@ -697,7 +693,7 @@ openerp.web.list_editable = function (instance) { throw new Error("Editor delegate's #edition_view must have a" + " non-empty arch") } - if (!(arch.tag === "form")) { + if (arch.tag !== "form") { throw new Error("Editor delegate's #edition_view must have a" + " 'form' root node"); } diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 48a108b2f01..fc67c7da24d 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -49,7 +49,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ if (last) { last.hide(); } - var item = _.extend({ + item = _.extend({ show: function(index) { this.widget.$el.show(); }, @@ -423,7 +423,7 @@ instance.web.ActionManager = instance.web.Widget.extend({ if (!(ClientWidget.prototype instanceof instance.web.Widget)) { var next; - if (next = ClientWidget(this, action)) { + if ((next = ClientWidget(this, action))) { return this.do_action(next, options); } return $.when(); @@ -677,7 +677,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.$el.find('.oe_view_title_text:first').text(title); }, add_breadcrumb: function(options) { - var options = options || {}; + options = options || {}; var self = this; var views = [this.active_view || this.views_src[0].view_type]; this.on('switch_mode', self, function(mode) { @@ -958,7 +958,6 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ view_type : 'list', view_mode : 'list' }); - break; case 'edit': this.do_edit_resource($option.data('model'), $option.data('id'), { name : $option.text() }); break; @@ -1000,7 +999,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ evt.currentTarget.selectedIndex = 0; }, do_edit_resource: function(model, id, action) { - var action = _.extend({ + action = _.extend({ res_model : model, res_id : id, type : 'ir.actions.act_window', @@ -1038,7 +1037,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ }, get_action_manager: function() { var cur = this; - while (cur = cur.getParent()) { + while ((cur = cur.getParent())) { if (cur instanceof instance.web.ActionManager) { return cur; } @@ -1176,7 +1175,7 @@ instance.web.Sidebar = instance.web.Widget.extend({ var self = this; self.getParent().sidebar_eval_context().done(function (sidebar_eval_context) { var ids = self.getParent().get_selected_ids(); - if (ids.length == 0) { + if (ids.length === 0) { instance.web.dialog($("
").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true }); return false; }