[merge] refactoring of ParentedMixin

bzr revid: nicolas.vanhoren@openerp.com-20120222162334-8jkpxt93jd3upo11
This commit is contained in:
niv-openerp 2012-02-22 17:23:34 +01:00
commit bd08a5d6e6
14 changed files with 161 additions and 137 deletions

View File

@ -148,7 +148,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog#
on_resized: function() {
//openerp.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height());
},
stop: function () {
destroy: function () {
// Destroy widget
this.close();
this.$element.dialog('destroy');
@ -240,7 +240,7 @@ openerp.web.Loading = openerp.web.OldWidget.extend(/** @lends openerp.web.Loadin
this.session.on_rpc_request.add_first(this.request_call);
this.session.on_rpc_response.add_last(this.response_call);
},
stop: function() {
destroy: function() {
this.session.on_rpc_request.remove(this.request_call);
this.session.on_rpc_response.remove(this.response_call);
this.on_rpc_event(-this.count);
@ -261,7 +261,7 @@ openerp.web.Loading = openerp.web.OldWidget.extend(/** @lends openerp.web.Loadin
$(".loading",this.$element).text(_.str.sprintf(
_t("Loading (%d)"), this.count));
$(".loading",this.$element).show();
this.widget_parent.$element.addClass('loading');
this.getParent().$element.addClass('loading');
} else {
this.count = 0;
clearTimeout(this.long_running_timer);
@ -271,7 +271,7 @@ openerp.web.Loading = openerp.web.OldWidget.extend(/** @lends openerp.web.Loadin
$.unblockUI();
}
$(".loading",this.$element).fadeOut();
this.widget_parent.$element.removeClass('loading');
this.getParent().$element.removeClass('loading');
}
}
});
@ -318,7 +318,7 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
self.hide();
});
},
stop: function () {
destroy: function () {
this.hide();
this.$option_id.empty();
@ -381,9 +381,9 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
var admin = result[1][0];
setTimeout(function () {
self.widget_parent.do_login(
self.getParent().do_login(
info.db, admin.login, admin.password);
self.stop();
self.destroy();
self.unblockUI();
});
});
@ -437,7 +437,7 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
if (self.db_list) {
self.db_list.push(self.to_object(fields)['db_name']);
self.db_list.sort();
self.widget_parent.set_db_list(self.db_list);
self.getParent().set_db_list(self.db_list);
}
var form_obj = self.to_object(fields);
self.wait_for_newdb(result, {
@ -469,7 +469,7 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
$db_list.find(':selected').remove();
if (self.db_list) {
self.db_list.splice(_.indexOf(self.db_list, db, true), 1);
self.widget_parent.set_db_list(self.db_list);
self.getParent().set_db_list(self.db_list);
}
self.do_notify("Dropping database", "The database '" + db + "' has been dropped");
});
@ -799,7 +799,7 @@ openerp.web.Header = openerp.web.OldWidget.extend(/** @lends openerp.web.Header
var inner_viewmanager = action_manager.inner_viewmanager;
inner_viewmanager.views[inner_viewmanager.active_view].controller.do_save()
.then(function() {
self.dialog.stop();
self.dialog.destroy();
// needs to refresh interface in case language changed
window.location.reload();
});
@ -1101,7 +1101,7 @@ openerp.web.WebClient = openerp.web.OldWidget.extend(/** @lends openerp.web.WebC
self.header.do_update();
self.menu.do_reload();
if(self.action_manager)
self.action_manager.stop();
self.action_manager.destroy();
self.action_manager = new openerp.web.ActionManager(self);
self.action_manager.appendTo($("#oe_app"));
self.bind_hashchange();
@ -1152,8 +1152,8 @@ openerp.web.WebClient = openerp.web.OldWidget.extend(/** @lends openerp.web.WebC
this.loading.appendTo(this.$element);
},
destroy_content: function() {
_.each(_.clone(this.widget_children), function(el) {
el.stop();
_.each(_.clone(this.getChildren()), function(el) {
el.destroy();
});
this.$element.children().remove();
},

View File

@ -925,6 +925,40 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
}
});
openerp.web.ParentedMixin = {
__parented_mixin: true,
setParent: function(parent) {
if(this.getParent()) {
if (this.getParent().__parented_mixin) {
this.getParent().__parented_children = _.without(this.getParent().getChildren(), this);
}
this.__parented_parent = undefined;
}
this.__parented_parent = parent;
if(parent && parent.__parented_mixin) {
if (!parent.__parented_children)
parent.__parented_children = [];
parent.__parented_children.push(this);
}
},
getParent: function() {
return this.__parented_parent;
},
getChildren: function() {
return this.__parented_children ? _.clone(this.__parented_children) : [];
},
isDestroyed: function() {
return this.__parented_destroyed;
},
destroy: function() {
_.each(this.getChildren(), function(el) {
el.destroy();
});
this.setParent(undefined);
this.__parented_destroyed = true;
},
};
/**
* Base class for all visual components. Provides a lot of functionalities helpful
* for the management of a part of the DOM.
@ -969,11 +1003,11 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
*
* And of course, when you don't need that widget anymore, just do:
*
* my_widget.stop();
* my_widget.destroy();
*
* That will kill the widget in a clean way and erase its content from the dom.
*/
openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.Widget# */{
openerp.web.Widget = openerp.web.CallbackEnabled.extend(openerp.web.ParentedMixin).extend(/** @lends openerp.web.Widget# */{
/**
* The name of the QWeb template that will be used for rendering. Must be
* redefined in subclasses or the default render() method can not be used.
@ -993,7 +1027,7 @@ openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.W
* @extends openerp.web.CallbackEnabled
*
* @param {openerp.web.Widget} parent Binds the current instance to the given Widget instance.
* When that widget is destroyed by calling stop(), the current instance will be
* When that widget is destroyed by calling destroy(), the current instance will be
* destroyed too. Can be null.
* @param {String} element_id Deprecated. Sets the element_id. Only useful when you want
* to bind the current Widget to an already existing part of the DOM, which is not compatible
@ -1006,13 +1040,19 @@ openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.W
this.$element = $(document.createElement(this.tag_name));
this.widget_parent = parent;
this.widget_children = [];
if(parent && parent.widget_children) {
parent.widget_children.push(this);
this.setParent(parent);
},
/**
* Destroys the current widget, also destroys all its children before destroying itself.
*/
destroy: function() {
_.each(this.getChildren(), function(el) {
el.destroy();
});
if(this.$element != null) {
this.$element.remove();
}
// useful to know if the widget was destroyed and should not be used anymore
this.widget_is_stopped = false;
this._super();
},
/**
* Renders the current widget and appends it to the given jQuery object or Widget.
@ -1104,42 +1144,26 @@ openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.W
start: function() {
return $.Deferred().done().promise();
},
/**
* Destroys the current widget, also destroys all its children before destroying itself.
*/
stop: function() {
_.each(_.clone(this.widget_children), function(el) {
el.stop();
});
if(this.$element != null) {
this.$element.remove();
}
if (this.widget_parent && this.widget_parent.widget_children) {
this.widget_parent.widget_children = _.without(this.widget_parent.widget_children, this);
}
this.widget_parent = null;
this.widget_is_stopped = true;
},
/**
* Informs the action manager to do an action. This supposes that
* the action manager can be found amongst the ancestors of the current widget.
* If that's not the case this method will simply return `false`.
*/
do_action: function(action, on_finished) {
if (this.widget_parent) {
return this.widget_parent.do_action(action, on_finished);
if (this.getParent()) {
return this.getParent().do_action(action, on_finished);
}
return false;
},
do_notify: function() {
if (this.widget_parent) {
return this.widget_parent.do_notify.apply(this,arguments);
if (this.getParent()) {
return this.getParent().do_notify.apply(this,arguments);
}
return false;
},
do_warn: function() {
if (this.widget_parent) {
return this.widget_parent.do_warn.apply(this,arguments);
if (this.getParent()) {
return this.getParent().do_warn.apply(this,arguments);
}
return false;
},
@ -1148,10 +1172,10 @@ openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.W
var def = $.Deferred().then(success, error);
var self = this;
openerp.connection.rpc(url, data). then(function() {
if (!self.widget_is_stopped)
if (!self.isDestroyed())
def.resolve.apply(def, arguments);
}, function() {
if (!self.widget_is_stopped)
if (!self.isDestroyed())
def.reject.apply(def, arguments);
});
return def.promise();

View File

@ -66,11 +66,11 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
this._super();
this.open({
buttons: [
{text: _t("Close"), click: function() { self.stop(); }},
{text: _t("Close"), click: function() { self.destroy(); }},
{text: _t("Import File"), click: function() { self.do_import(); }, 'class': 'oe-dialog-import-button'}
],
close: function(event, ui) {
self.stop();
self.destroy();
}
});
this.toggle_import_button(false);
@ -201,10 +201,10 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
return;
}
if (results['success']) {
if (this.widget_parent.widget_parent.active_view == "list") {
this.widget_parent.reload_content();
if (this.getParent().getParent().active_view == "list") {
this.getParent().reload_content();
}
this.stop();
this.destroy();
return;
}
@ -358,7 +358,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
}
return true;
},
stop: function() {
destroy: function() {
this.$element.remove();
this._super();
}

View File

@ -303,10 +303,10 @@ openerp.web.SearchView = openerp.web.OldWidget.extend(/** @lends openerp.web.Sea
});
self.rpc('/web/searchview/add_to_dashboard', {
menu_id: menu_id,
action_id: self.widget_parent.action.id,
action_id: self.getParent().action.id,
context_to_save: context,
domain: domain,
view_mode: self.widget_parent.active_view,
view_mode: self.getParent().active_view,
name: title
}, function(r) {
if (r === false) {
@ -552,7 +552,7 @@ openerp.web.search.Widget = openerp.web.OldWidget.extend( /** @lends openerp.web
* "Stops" the widgets. Called when the view destroys itself, this
* lets the widgets clean up after themselves.
*/
stop: function () {
destroy: function () {
delete this.view;
this._super();
},
@ -1114,7 +1114,7 @@ openerp.web.search.ExtendedSearch = openerp.web.search.Input.extend({
if(this.$element.closest("table.oe-searchview-render-line").css("display") == "none") {
return null;
}
return _.reduce(this.widget_children,
return _.reduce(this.getChildren(),
function(mem, x) { return mem.concat(x.get_domain());}, []);
},
on_activate: function() {
@ -1133,9 +1133,9 @@ openerp.web.search.ExtendedSearch = openerp.web.search.Input.extend({
}
},
check_last_element: function() {
_.each(this.widget_children, function(x) {x.set_last_group(false);});
if (this.widget_children.length >= 1) {
this.widget_children[this.widget_children.length - 1].set_last_group(true);
_.each(this.getChildren(), function(x) {x.set_last_group(false);});
if (this.getChildren().length >= 1) {
this.getChildren()[this.getChildren().length - 1].set_last_group(true);
}
}
});
@ -1148,7 +1148,7 @@ openerp.web.search.ExtendedSearchGroup = openerp.web.OldWidget.extend({
},
add_prop: function() {
var prop = new openerp.web.search.ExtendedSearchProposition(this, this.fields);
var render = prop.render({'index': this.widget_children.length - 1});
var render = prop.render({'index': this.getChildren().length - 1});
this.$element.find('.searchview_extended_propositions_list').append(render);
prop.start();
},
@ -1159,11 +1159,11 @@ openerp.web.search.ExtendedSearchGroup = openerp.web.OldWidget.extend({
_this.add_prop();
});
this.$element.find('.searchview_extended_delete_group').click(function () {
_this.stop();
_this.destroy();
});
},
get_domain: function() {
var props = _(this.widget_children).chain().map(function(x) {
var props = _(this.getChildren()).chain().map(function(x) {
return x.get_proposition();
}).compact().value();
var choice = this.$element.find(".searchview_extended_group_choice").val();
@ -1172,10 +1172,10 @@ openerp.web.search.ExtendedSearchGroup = openerp.web.OldWidget.extend({
_.map(_.range(_.max([0,props.length - 1])), function() { return op; }),
props);
},
stop: function() {
var parent = this.widget_parent;
if (this.widget_parent.widget_children.length == 1)
this.widget_parent.hide();
destroy: function() {
var parent = this.getParent();
if (this.getParent().getChildren().length == 1)
this.getParent().hide();
this._super();
parent.check_last_element();
},
@ -1210,16 +1210,16 @@ openerp.web.search.ExtendedSearchProposition = openerp.web.OldWidget.extend(/**
_this.changed();
});
this.$element.find('.searchview_extended_delete_prop').click(function () {
_this.stop();
_this.destroy();
});
},
stop: function() {
destroy: function() {
var parent;
if (this.widget_parent.widget_children.length == 1)
parent = this.widget_parent;
if (this.getParent().getChildren().length == 1)
parent = this.getParent();
this._super();
if (parent)
parent.stop();
parent.destroy();
},
changed: function() {
var nval = this.$element.find(".searchview_extended_prop_field").val();
@ -1235,7 +1235,7 @@ openerp.web.search.ExtendedSearchProposition = openerp.web.OldWidget.extend(/**
select_field: function(field) {
var self = this;
if(this.attrs.selected != null) {
this.value.stop();
this.value.destroy();
this.value = null;
this.$element.find('.searchview_extended_prop_op').html('');
}

View File

@ -1002,10 +1002,10 @@ openerp.web.ViewEditor = openerp.web.OldWidget.extend({
$.when(action_manager.do_action(action)).then(function() {
var controller = action_manager.dialog_viewmanager.views['form'].controller;
controller.on_button_cancel.add_last(function(){
action_manager.stop()
action_manager.destroy()
});
controller.do_save.add_last(function(){
action_manager.stop();
action_manager.destroy();
var value =controller.fields.name.value;
self.add_node_dialog.$element.find('select[id=field_value]').append($("<option selected></option>").attr("value",value).text(value));
_.detect(self.add_widget,function(widget){

View File

@ -74,13 +74,13 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
}, this.on_loaded);
}
},
stop: function() {
destroy: function() {
if (this.sidebar) {
this.sidebar.attachments.stop();
this.sidebar.stop();
this.sidebar.attachments.destroy();
this.sidebar.destroy();
}
_.each(this.widgets, function(w) {
w.stop();
w.destroy();
});
this._super();
},
@ -923,7 +923,7 @@ openerp.web.form.Widget = openerp.web.OldWidget.extend(/** @lends openerp.web.fo
this.width = this.node.attrs.width;
},
stop: function() {
destroy: function() {
this._super.apply(this, arguments);
$.fn.tipsy.clear();
},
@ -2554,7 +2554,7 @@ openerp.web.form.FieldOne2Many = openerp.web.form.Field.extend({
this.previous_readonly = this.readonly;
if (this.viewmanager) {
this.is_loaded = this.is_loaded.pipe(function() {
self.viewmanager.stop();
self.viewmanager.destroy();
return $.when(self.load_views()).then(function() {
self.reload_current_view();
});
@ -2734,7 +2734,7 @@ openerp.web.form.FieldMany2Many = openerp.web.form.Field.extend({
this.previous_readonly = this.readonly;
if (this.list_view) {
this.is_loaded = this.is_loaded.pipe(function() {
self.list_view.stop();
self.list_view.destroy();
return $.when(self.load_view()).then(function() {
self.reload_content();
});
@ -2782,7 +2782,7 @@ openerp.web.form.Many2ManyListView = openerp.web.ListView.extend(/** @lends open
var pop = new openerp.web.form.FormOpenPopup(this);
pop.show_element(this.dataset.model, id, this.m2m_field.build_context(), {
title: _t("Open: ") + this.name,
readonly: this.widget_parent.is_readonly()
readonly: this.getParent().is_readonly()
});
pop.on_write_completed.add_last(function() {
self.reload_content();
@ -2866,7 +2866,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
setup_search_view: function(search_defaults) {
var self = this;
if (this.searchview) {
this.searchview.stop();
this.searchview.destroy();
}
this.searchview = new openerp.web.SearchView(this,
this.dataset, false, search_defaults);
@ -2896,7 +2896,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
$buttons.prepend(QWeb.render("SelectCreatePopup.search.buttons"));
var $cbutton = $buttons.find(".oe_selectcreatepopup-search-close");
$cbutton.click(function() {
self.stop();
self.destroy();
});
var $sbutton = $buttons.find(".oe_selectcreatepopup-search-select");
if(self.options.disable_multiple_selection) {
@ -2904,7 +2904,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
}
$sbutton.click(function() {
self.on_select_elements(self.selected_ids);
self.stop();
self.destroy();
});
});
});
@ -2988,7 +2988,7 @@ openerp.web.form.SelectCreatePopup = openerp.web.OldWidget.extend(/** @lends ope
if (this.created_elements.length > 0) {
this.on_select_elements(this.created_elements);
}
this.stop();
this.destroy();
},
on_default_get: function(res) {}
});
@ -2999,7 +2999,7 @@ openerp.web.form.SelectCreateListView = openerp.web.ListView.extend({
},
select_record: function(index) {
this.popup.on_select_elements([this.dataset.ids[index]]);
this.popup.stop();
this.popup.destroy();
},
do_select: function(ids, records) {
this._super(ids, records);
@ -3075,12 +3075,12 @@ openerp.web.form.FormOpenPopup = openerp.web.OldWidget.extend(/** @lends openerp
var $nbutton = $buttons.find(".oe_formopenpopup-form-save");
$nbutton.click(function() {
self.view_form.do_save().then(function() {
self.stop();
self.destroy();
});
});
var $cbutton = $buttons.find(".oe_formopenpopup-form-close");
$cbutton.click(function() {
self.stop();
self.destroy();
});
if (self.options.readonly) {
$nbutton.hide();

View File

@ -96,7 +96,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
if (this._limit === undefined) {
this._limit = (this.options.limit
|| this.defaults.limit
|| (this.widget_parent.action || {}).limit
|| (this.getParent().action || {}).limit
|| 80);
}
return this._limit;

View File

@ -139,7 +139,7 @@ openerp.web.list_editable = function (openerp) {
}
cancelled.then(function () {
self.view.unpad_columns();
self.edition_form.stop();
self.edition_form.destroy();
self.edition_form.$element.remove();
delete self.edition_form;
delete self.edition_id;

View File

@ -30,31 +30,31 @@ session.web.ActionManager = session.web.OldWidget.extend({
},
dialog_stop: function () {
if (this.dialog) {
this.dialog_viewmanager.stop();
this.dialog_viewmanager.destroy();
this.dialog_viewmanager = null;
this.dialog.stop();
this.dialog.destroy();
this.dialog = null;
}
},
content_stop: function () {
if (this.inner_viewmanager) {
this.inner_viewmanager.stop();
this.inner_viewmanager.destroy();
this.inner_viewmanager = null;
}
if (this.client_widget) {
this.client_widget.stop();
this.client_widget.destroy();
this.client_widget = null;
}
},
do_push_state: function(state) {
if (this.widget_parent && this.widget_parent.do_push_state) {
if (this.getParent() && this.getParent().do_push_state) {
if (this.inner_action) {
state['model'] = this.inner_action.res_model;
if (this.inner_action.id) {
state['action_id'] = this.inner_action.id;
}
}
this.widget_parent.do_push_state(state);
this.getParent().do_push_state(state);
}
},
do_load_state: function(state, warm) {
@ -142,7 +142,7 @@ session.web.ActionManager = session.web.OldWidget.extend({
if(on_close)
this.dialog.on_close.add(on_close);
} else {
this.dialog_viewmanager.stop();
this.dialog_viewmanager.destroy();
}
this.dialog.dialog_title = action.name;
this.dialog_viewmanager = new session.web.ViewManagerAction(this, action);
@ -150,7 +150,7 @@ session.web.ActionManager = session.web.OldWidget.extend({
this.dialog.open();
} else {
if(action.menu_id) {
return this.widget_parent.do_action(action, function () {
return this.getParent().do_action(action, function () {
session.webclient.menu.open_menu(action.menu_id);
});
}
@ -209,7 +209,7 @@ session.web.ActionManager = session.web.OldWidget.extend({
window.open(action.url, action.target === 'self' ? '_self' : '_blank');
},
ir_ui_menu: function (action) {
this.widget_parent.do_action(action);
this.getParent().do_action(action);
}
});
@ -385,7 +385,7 @@ session.web.ViewManager = session.web.OldWidget.extend(/** @lends session.web.V
setup_search_view: function(view_id, search_defaults) {
var self = this;
if (this.searchview) {
this.searchview.stop();
this.searchview.destroy();
}
this.searchview = new session.web.SearchView(
this, this.dataset,
@ -680,9 +680,9 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner
});
},
do_push_state: function(state) {
if (this.widget_parent && this.widget_parent.do_push_state) {
if (this.getParent() && this.getParent().do_push_state) {
state["view_type"] = this.active_view;
this.widget_parent.do_push_state(state);
this.getParent().do_push_state(state);
}
},
do_load_state: function(state, warm) {
@ -702,7 +702,7 @@ session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepner
},
shortcut_check : function(view) {
var self = this;
var grandparent = this.widget_parent && this.widget_parent.widget_parent;
var grandparent = this.getParent() && this.getParent().getParent();
// display shortcuts if on the first view for the action
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
if (!this.action.name ||
@ -796,8 +796,8 @@ session.web.Sidebar = session.web.OldWidget.extend({
},
add_default_sections: function() {
var self = this,
view = this.widget_parent,
view_manager = view.widget_parent,
view = this.getParent(),
view_manager = view.getParent(),
action = view_manager.action;
if (this.session.uid === 1) {
this.add_section(_t('Customize'), 'customize');
@ -912,8 +912,8 @@ session.web.Sidebar = session.web.OldWidget.extend({
},
on_item_action_clicked: function(item) {
var self = this;
self.widget_parent.sidebar_context().then(function (context) {
var ids = self.widget_parent.get_selected_ids();
self.getParent().sidebar_context().then(function (context) {
var ids = self.getParent().get_selected_ids();
if (ids.length == 0) {
//TODO: make prettier warning?
openerp.web.dialog($("<div />").text(_t("You must choose at least one record.")), {
@ -925,7 +925,7 @@ session.web.Sidebar = session.web.OldWidget.extend({
var additional_context = _.extend({
active_id: ids[0],
active_ids: ids,
active_model: self.widget_parent.dataset.model
active_model: self.getParent().dataset.model
}, context);
self.rpc("/web/action/load", {
action_id: item.action.id,
@ -937,7 +937,7 @@ session.web.Sidebar = session.web.OldWidget.extend({
result.result.flags.new_window = true;
self.do_action(result.result, function () {
// reload view
self.widget_parent.reload();
self.getParent().reload();
});
});
});
@ -1111,8 +1111,8 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
var self = this;
var result_handler = function () {
if (on_closed) { on_closed.apply(null, arguments); }
if (self.widget_parent && self.widget_parent.on_action_executed) {
return self.widget_parent.on_action_executed.apply(null, arguments);
if (self.getParent() && self.getParent().on_action_executed) {
return self.getParent().on_action_executed.apply(null, arguments);
}
};
var context = new session.web.CompoundContext(dataset.get_context(), action_data.context || {});
@ -1184,8 +1184,8 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
this.$element.hide();
},
do_push_state: function(state) {
if (this.widget_parent && this.widget_parent.do_push_state) {
this.widget_parent.do_push_state(state);
if (this.getParent() && this.getParent().do_push_state) {
this.getParent().do_push_state(state);
}
},
do_load_state: function(state, warm) {

View File

@ -42,7 +42,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
this._super();
return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': true}, this.on_loaded);
},
stop: function() {
destroy: function() {
scheduler.clearAll();
this._super();
},

View File

@ -238,9 +238,9 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
this.$element.html(rendered);
},
do_reload: function() {
var view_manager = this.view.widget_parent,
action_manager = view_manager.widget_parent;
this.view.stop();
var view_manager = this.view.getParent(),
action_manager = view_manager.getParent();
this.view.destroy();
action_manager.do_action(view_manager.action);
}
});
@ -341,7 +341,7 @@ openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({
});
})
.delegate('li:not(.oe-done)', 'click', function () {
self.widget_parent.widget_parent.widget_parent.do_execute_action({
self.getParent().getParent().getParent().do_execute_action({
type: 'object',
name: 'action_launch'
}, self.dataset,
@ -463,8 +463,8 @@ openerp.web_dashboard.ApplicationInstaller = openerp.web.OldWidget.extend({
});
return r;
},
stop: function() {
this.action_manager.stop();
destroy: function() {
this.action_manager.destroy();
return this._super();
}
});

View File

@ -33,7 +33,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
this.renderer = null;
},
stop: function () {
destroy: function () {
if (this.renderer) {
clearTimeout(this.renderer);
}
@ -97,7 +97,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
this.$element.html(QWeb.render("GraphView", {
"fields_view": this.fields_view,
"chart": this.chart,
'element_id': this.widget_parent.element_id
'element_id': this.getParent().element_id
}));
var fields = _(this.columns).pluck('name').concat([this.abscissa]);
@ -272,7 +272,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
self.renderer = null;
var charts = new dhtmlXChart({
view: view_chart,
container: self.widget_parent.element_id+"-"+self.chart+"chart",
container: self.getParent().element_id+"-"+self.chart+"chart",
value:"#"+group_list[0].group+"#",
gradient: (self.chart == "bar") ? "3d" : "light",
alpha: (self.chart == "area") ? 0.6 : 1,
@ -309,8 +309,8 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
}
}
});
self.$element.find("#"+self.widget_parent.element_id+"-"+self.chart+"chart").width(
self.$element.find("#"+self.widget_parent.element_id+"-"+self.chart+"chart").width()+120);
self.$element.find("#"+self.getParent().element_id+"-"+self.chart+"chart").width(
self.$element.find("#"+self.getParent().element_id+"-"+self.chart+"chart").width()+120);
for (var m = 1; m<group_list.length;m++){
var column = group_list[m];
@ -333,8 +333,8 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
});
}
charts.parse(results, "json");
self.$element.find("#"+self.widget_parent.element_id+"-"+self.chart+"chart").height(
self.$element.find("#"+self.widget_parent.element_id+"-"+self.chart+"chart").height()+50);
self.$element.find("#"+self.getParent().element_id+"-"+self.chart+"chart").height(
self.$element.find("#"+self.getParent().element_id+"-"+self.chart+"chart").height()+50);
charts.attachEvent("onItemClick", function(id) {
self.open_list_view(charts.get(id));
});
@ -354,7 +354,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
self.renderer = null;
var chart = new dhtmlXChart({
view:"pie3D",
container:self.widget_parent.element_id+"-piechart",
container:self.getParent().element_id+"-piechart",
value:"#"+self.ordinate+"#",
pieInnerText:function(obj) {
var sum = chart.sum("#"+self.ordinate+"#");
@ -406,8 +406,8 @@ openerp.web_graph.GraphView = openerp.web.View.extend({
}
var views;
if (this.widget_parent.action) {
views = this.widget_parent.action.views;
if (this.getParent().action) {
views = this.getParent().action.views;
if (!_(views).detect(function (view) {
return view[1] === 'list' })) {
views = [[false, 'list']].concat(views);

View File

@ -176,7 +176,7 @@ openerp.web_kanban.KanbanView = openerp.web.View.extend({
},
do_clear_groups: function() {
_.each(this.groups, function(group) {
group.stop();
group.destroy();
});
this.groups = [];
this.$element.find('.oe_kanban_groups_headers, .oe_kanban_groups_records').empty();
@ -328,7 +328,7 @@ openerp.web_kanban.KanbanGroup = openerp.web.OldWidget.extend({
this.$has_been_started.resolve();
return def;
},
stop: function() {
destroy: function() {
this._super();
if (this.$records) {
this.$records.remove();
@ -470,7 +470,7 @@ openerp.web_kanban.KanbanRecord = openerp.web.OldWidget.extend({
if (confirm(_t("Are you sure you want to delete this record ?"))) {
return $.when(this.view.dataset.unlink([this.id])).then(function() {
self.group.remove_record(self.id);
self.stop();
self.destroy();
});
}
},
@ -521,7 +521,7 @@ openerp.web_kanban.KanbanRecord = openerp.web.OldWidget.extend({
self.set_record(records[0]);
self.do_render();
} else {
self.stop();
self.destroy();
}
});
},

View File

@ -12,7 +12,7 @@ openerp.web_process = function (openerp) {
},
process_check: function() {
var self = this,
grandparent = this.widget_parent && this.widget_parent.widget_parent,
grandparent = this.getParent() && this.getParent().getParent(),
view = this.views[this.views_src[0].view_type],
$process_view = this.$element.find('.oe-process-view');
if (!(grandparent instanceof openerp.web.WebClient) ||
@ -128,7 +128,7 @@ openerp.web_process = function (openerp) {
this.$element.find('#edit_process').click(function() {
self.edit_process_view();
});
var $parent = this.widget_parent.$element;
var $parent = this.getParent().$element;
$parent.find('#change_process').click(function() {
self.process_selection = false,
self.process_id = $parent.find('#select_process').val(),