From 32d90f6014d41bfbee8550d9d592dac550030c70 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 6 Mar 2013 15:55:27 +0100 Subject: [PATCH] [FIX] cleanup m2o field events when reloading m2o fields The big issue was the hooking on the closest ui-dialog's scroll event: if an m2o in a dialog (e.g. wizard-type situations) toggled state from editable to readonly (workflow action of some sort), the event hook would remain, and call .$input.autocomplete("widget") which would blow up because the autocompletion widget hasn't been re-initialized. Take care to fully unbind all events during the reload process to avoid this issue (and potentially other such as duplicate bindings and the like). lp bug: https://launchpad.net/bugs/1146321 fixed bzr revid: xmo@openerp.com-20130306145527-sssv7ocfvqxgv896 --- addons/web/static/src/js/view_form.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 7ba45c865f3..07f06fa89ef 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3020,6 +3020,26 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc if (!this.get("effective_readonly")) this.render_editable(); }, + destroy_content: function () { + if (this.$drop_down) { + this.$drop_down.off('click'); + delete this.$drop_down; + } + if (this.$input) { + this.$input.closest(".ui-dialog .ui-dialog-content").off('scroll'); + this.$input.off('keyup blur autocompleteclose autocompleteopen ' + + 'focus focusout change keydown'); + delete this.$input; + } + if (this.$follow_button) { + this.$follow_button.off('blur focus click'); + delete this.$follow_button; + } + }, + destroy: function () { + this.destroy_content(); + return this._super(); + }, init_error_displayer: function() { // nothing },