summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-08-07 11:23:17 +0200
committerXavier Morel <xmo@openerp.com>2012-08-07 11:23:17 +0200
commit741a1541dac31f966b9f86b2fd663d1a89ba413f (patch)
treed8fc7cc6274252baac06b539f54a1546c811c09f /addons/web/static/src
parentd9291d50c817f0eeb6210909322b241d21b3484e (diff)
[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
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/view_list.js11
-rw-r--r--addons/web/static/src/js/view_list_editable.js9
2 files changed, 14 insertions, 6 deletions
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 57be3ca6db1..4bce8d639f8 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -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) {
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index 3a574c30e56..78fef767f5a 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -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);
});
},
/**