[FIX] action button on row being *created* in editable list view
Altered action button workflow: * Action callback (passed to ``do_button_action``) now *takes* a record id instead of closing over it, in case the original list does not have an id to start with * ``handle_button`` partially applies the id *it* got to the callback via ``_.bind`` * Editable list view override of ``do_button_action`` uses ``id`` it got from ``ensure_saved`` in case it got id=false in bzr revid: xmo@openerp.com-20120807092317-wk0xyfzrhxc89t94
This commit is contained in:
parent
d9291d50c8
commit
741a1541da
|
@ -674,6 +674,10 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
* Base handling of buttons, can be called when overriding do_button_action
|
||||
* in order to bypass parent overrides.
|
||||
*
|
||||
* The callback will be provided with the ``id`` as its parameter, in case
|
||||
* handle_button's caller had to alter the ``id`` (or even create one)
|
||||
* while not being ``callback``'s creator.
|
||||
*
|
||||
* This method should not be overridden.
|
||||
*
|
||||
* @param {String} name action name
|
||||
|
@ -699,7 +703,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
|||
c.add(action.context);
|
||||
}
|
||||
action.context = c;
|
||||
this.do_execute_action(action, this.dataset, id, callback);
|
||||
this.do_execute_action(
|
||||
action, this.dataset, id, _.bind(callback, null, id));
|
||||
},
|
||||
/**
|
||||
* Handles the activation of a record (clicking on it)
|
||||
|
@ -991,8 +996,8 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
|
|||
// of digits, nice when storing actual numbers, not nice when
|
||||
// storing strings composed only of digits. Force the action
|
||||
// name to be a string
|
||||
$(self).trigger('action', [field.toString(), record_id, function () {
|
||||
return self.reload_record(self.records.get(record_id));
|
||||
$(self).trigger('action', [field.toString(), record_id, function (id) {
|
||||
return self.reload_record(self.records.get(id));
|
||||
}]);
|
||||
})
|
||||
.delegate('a', 'click', function (e) {
|
||||
|
|
|
@ -135,10 +135,13 @@ openerp.web.list_editable = function (instance) {
|
|||
make_editor: function () {
|
||||
return new instance.web.list.Editor(this);
|
||||
},
|
||||
do_button_action: function () {
|
||||
do_button_action: function (name, id, callback) {
|
||||
var self = this, args = arguments;
|
||||
this.ensure_saved().then(function () {
|
||||
self.handle_button.apply(self, args);
|
||||
this.ensure_saved().then(function (done) {
|
||||
if (!id && done.created) {
|
||||
id = done.record.get('id');
|
||||
}
|
||||
self.handle_button.call(self, name, id, callback);
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue