[FIX] action-type button from a list row being edited in an o2m
Issue 575065 Flow for a button[@type=action] requires going through multiple RPC calls to execute action. Due to reloading behavior of o2m-list on actions (saves containing form then executes action then reloads row), internal form view gets removed while e.g. server action is being fetched (in Views#do_execute_action). Problem: there is guard on ``rpc`` call which drops response to stopped widget (Widget#rpc) => action/load call never returns successfully because linked form is dead. Solution: instead of calling View#do_execute_action via the formview, call it via the listview (do_execute_action was already partially overridden to change the ``on_close`` callback, override it further). => widget still lives, and rpc requests execute correctly leading to all actions being correctly called (mostly). bzr revid: xmo@openerp.com-20120629105325-vmwpyi7w3pc33sg9
This commit is contained in:
@@ -2752,12 +2752,16 @@ openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({
|
||||
self.cancel_pending_edition();
|
||||
});
|
||||
|
||||
// Overload execute_action on the edition form to perform a simple
|
||||
// reload_record after the action is done, rather than fully
|
||||
// reload the parent view (or something)
|
||||
var _execute_action = self.edition_form.do_execute_action;
|
||||
// Replace form's do_execute_action by a call to listview's:
|
||||
// because the form view is actually destroyed at one point, the
|
||||
// RPC request to load&execute the action may get dropped on the
|
||||
// floor in some cases (core.js:1173) leading to the flow not
|
||||
// terminating for complex cases (a button of type action, which
|
||||
// needs 2 or 3 RPC roundtrip to execute the action fully).
|
||||
// => because do_execute_action really is on View, use the
|
||||
// listview's
|
||||
self.edition_form.do_execute_action = function (action, dataset, record_id, _callback) {
|
||||
return _execute_action.call(this, action, dataset, record_id, function () {
|
||||
return self.view.do_execute_action(action, dataset, record_id, function () {
|
||||
self.view.reload_record(
|
||||
self.view.records.get(record_id));
|
||||
});
|
||||
|
||||
@@ -1166,7 +1166,11 @@ session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
|
||||
args.push(context);
|
||||
return dataset.call_button(action_data.name, args, handler);
|
||||
} else if (action_data.type=="action") {
|
||||
return this.rpc('/web/action/load', { action_id: parseInt(action_data.name, 10), context: context, do_not_eval: true}, handler);
|
||||
return this.rpc('/web/action/load', {
|
||||
action_id: parseInt(action_data.name, 10),
|
||||
context: context,
|
||||
do_not_eval: true
|
||||
}).then(handler);
|
||||
} else {
|
||||
return dataset.exec_workflow(record_id, action_data.name, handler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user