Merge lp:~stan/openobject-client-web/ajaxo2m into lp:openobject-client-web/trunk

Proposed by Tristan Hill
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~stan/openobject-client-web/ajaxo2m
Merge into: lp:openobject-client-web/trunk
Diff against target: 51 lines (+19/-4)
2 files modified
addons/openerp/controllers/templates/openo2m.mako (+1/-1)
addons/openerp/static/javascript/form.js (+18/-3)
To merge this branch: bzr merge lp:~stan/openobject-client-web/ajaxo2m
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Disapprove
Review via email: mp+53842@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

While this looks like it fixes the issue from afar, it does not:

* Most if not all form submissions should be ajaxified by now, using delegation. In this precise case, the submission is routed to line 240 (in 6.0, not sure about the line in trnuk but it should be roughly the same) in the file 'openerp.base.js'. No need to create a "special" ajaxified version

* Furthermore, while the result *looks* ok by doing an urlencoded POST, the attached file is *not* sent to the server, only the name is correctly set.

I fear the underlying brokenness of binaries handling in the web client make this harder than a trivial fix (https://code.launchpad.net/~openerp-dev/openobject-client-web/6.0-opw-4009-al/+merge/50846 also tries to fix it, but it did not seem to work correctly in my tests, and it certainly does not fix this issue)

review: Disapprove

Unmerged revisions

4538. By Tristan Hill

[FIX] use ajax for one2many save and close which works in an iframe

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/templates/openo2m.mako'
2--- addons/openerp/controllers/templates/openo2m.mako 2010-12-28 07:29:19 +0000
3+++ addons/openerp/controllers/templates/openo2m.mako 2011-03-17 15:21:31 +0000
4@@ -31,7 +31,7 @@
5 <tr>
6 % if form.screen.editable:
7 <td class="save_close">
8- <button onclick="submit_form('save_and_close'); return false;" style="height: 20px;" class="button-a">${_("Save & Close")}</button>
9+ <button onclick="ajax_submit_form('save_and_close'); return false;" style="height: 20px;" class="button-a">${_("Save & Close")}</button>
10 </td>
11 <td class="save_close">
12 <button onclick="submit_form('save'); return false;" style="height: 20px;" class="button-a">${_("Save & New")}</button>
13
14=== modified file 'addons/openerp/static/javascript/form.js'
15--- addons/openerp/static/javascript/form.js 2011-02-16 08:57:33 +0000
16+++ addons/openerp/static/javascript/form.js 2011-03-17 15:21:31 +0000
17@@ -210,7 +210,7 @@
18 }
19
20
21-function submit_form(action, src, target){
22+function submit_form(action, src, target, ajax){
23
24 if (openobject.http.AJAX_COUNT > 0) {
25 callLater(1, submit_form, action, src, target);
26@@ -245,8 +245,23 @@
27 // action when creating an activity
28 $form[0].setAttribute('action', action);
29 $form.attr("target", target);
30- $form.submit();
31-}
32+
33+ if (ajax) {
34+ jQuery.post(action, $form.serialize(),
35+ function(data) {
36+ $form.after(data);
37+ });
38+ } else {
39+ $form.submit();
40+ }
41+
42+}
43+
44+
45+function ajax_submit_form(action, src, target){
46+ submit_form(action, src, target, true);
47+}
48+
49
50 function pager_action(src){
51 var $src = jQuery(src);