[IMP] Remove add_last in on_created method

bzr revid: ggh@tinyerp.com-20121008094924-uawry36sh9ffz8ut
This commit is contained in:
ggh-openerp 2012-10-08 15:19:24 +05:30
parent 55bcd978af
commit f893835350
3 changed files with 8 additions and 6 deletions

View File

@ -131,6 +131,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
e.preventDefault(); e.preventDefault();
} }
}); });
self.on('on_rec_create', self, self.on_created);
}, },
destroy: function() { destroy: function() {
_.each(this.get_widgets(), function(w) { _.each(this.get_widgets(), function(w) {
@ -778,7 +779,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var def = $.Deferred(); var def = $.Deferred();
$.when(this.has_been_loaded).then(function() { $.when(this.has_been_loaded).then(function() {
self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) { self.dataset.call('copy', [self.datarecord.id, {}, self.dataset.context]).then(function(new_id) {
return self.on_created({ result : new_id }); return self.trigger('on_rec_create',{ result : new_id });
}).then(function() { }).then(function() {
return self.to_edit_mode(); return self.to_edit_mode();
}).then(function() { }).then(function() {
@ -859,7 +860,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
if (!self.datarecord.id) { if (!self.datarecord.id) {
// Creation save // Creation save
save_deferral = self.dataset.create(values).pipe(function(r) { save_deferral = self.dataset.create(values).pipe(function(r) {
return self.on_created(r, prepend_on_create); return self.trigger('on_rec_create', r, prepend_on_create);
}, null); }, null);
} else if (_.isEmpty(values) && ! self.force_dirty) { } else if (_.isEmpty(values) && ! self.force_dirty) {
// Not dirty, noop save // Not dirty, noop save
@ -1622,12 +1623,13 @@ instance.web.form.FormDialog = instance.web.Dialog.extend({
return this; return this;
}, },
start: function() { start: function() {
var self = this;
this._super(); this._super();
this.form = new instance.web.FormView(this, this.dataset, this.view_id, { this.form = new instance.web.FormView(this, this.dataset, this.view_id, {
pager: false pager: false
}); });
this.form.appendTo(this.$el); this.form.appendTo(this.$el);
this.form.on_created.add_last(this.on_form_dialog_saved); this.form.on('on_rec_create', self, this.on_form_dialog_saved);
this.form.on_saved.add_last(this.on_form_dialog_saved); this.form.on_saved.add_last(this.on_form_dialog_saved);
return this; return this;
}, },

View File

@ -458,7 +458,7 @@ instance.web_calendar.CalendarFormDialog = instance.web.Dialog.extend({
pager: false pager: false
}); });
var def = this.form.appendTo(this.$el); var def = this.form.appendTo(this.$el);
this.form.on_created.add_last(this.on_form_dialog_saved); this.form.on('on_rec_create', self, this.on_form_dialog_saved);
this.form.on_saved.add_last(this.on_form_dialog_saved); this.form.on_saved.add_last(this.on_form_dialog_saved);
this.form.on_button_cancel = function() { this.form.on_button_cancel = function() {
self.close(); self.close();

View File

@ -195,7 +195,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var am = instance.webclient.action_manager; var am = instance.webclient.action_manager;
var form = am.dialog_widget.views.form.controller; var form = am.dialog_widget.views.form.controller;
form.on_button_cancel.add_last(am.dialog.on_close); form.on_button_cancel.add_last(am.dialog.on_close);
form.on_created.add_last(function(r) { form.on('on_rec_create', self, function(r) {
(new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r.result]).then(function(new_record) { (new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r.result]).then(function(new_record) {
am.dialog.on_close(); am.dialog.on_close();
var domain = self.dataset.domain.slice(0); var domain = self.dataset.domain.slice(0);
@ -673,7 +673,7 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
var am = instance.webclient.action_manager; var am = instance.webclient.action_manager;
var form = am.dialog_widget.views.form.controller; var form = am.dialog_widget.views.form.controller;
form.on_button_cancel.add_last(am.dialog.on_close); form.on_button_cancel.add_last(am.dialog.on_close);
form.on_saved.add_last(function() { form.on('on_saved', self, function() {
am.dialog.on_close(); am.dialog.on_close();
self.view.do_reload(); self.view.do_reload();
}); });