← Back to team overview

openerp-dev-web team mailing list archive

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

 

Tristan Hill (credativ) has proposed merging lp:~stan/openobject-client-web/ajaxo2m into lp:openobject-client-web.

Requested reviews:
  OpenERP SA's Web Client R&D (openerp-dev-web)
Related bugs:
  Bug #730894 in OpenERP Web Client: "CRM send mail attachment doesn't save/send file"
  https://bugs.launchpad.net/openobject-client-web/+bug/730894

For more details, see:
https://code.launchpad.net/~stan/openobject-client-web/ajaxo2m/+merge/53842

fix for https://bugs.launchpad.net/openobject-client-web/+bug/730894
-- 
https://code.launchpad.net/~stan/openobject-client-web/ajaxo2m/+merge/53842
Your team OpenERP SA's Web Client R&D is requested to review the proposed merge of lp:~stan/openobject-client-web/ajaxo2m into lp:openobject-client-web.
=== modified file 'addons/openerp/controllers/templates/openo2m.mako'
--- addons/openerp/controllers/templates/openo2m.mako	2010-12-28 07:29:19 +0000
+++ addons/openerp/controllers/templates/openo2m.mako	2011-03-17 15:21:31 +0000
@@ -31,7 +31,7 @@
                         <tr>
                             % if form.screen.editable:
                                 <td class="save_close">
-                                    <button onclick="submit_form('save_and_close'); return false;" style="height: 20px;" class="button-a">${_("Save & Close")}</button>
+                                    <button onclick="ajax_submit_form('save_and_close'); return false;" style="height: 20px;" class="button-a">${_("Save & Close")}</button>
                                 </td>
                                 <td class="save_close">
                                     <button onclick="submit_form('save'); return false;" style="height: 20px;" class="button-a">${_("Save & New")}</button>

=== modified file 'addons/openerp/static/javascript/form.js'
--- addons/openerp/static/javascript/form.js	2011-02-16 08:57:33 +0000
+++ addons/openerp/static/javascript/form.js	2011-03-17 15:21:31 +0000
@@ -210,7 +210,7 @@
 }
 
 
-function submit_form(action, src, target){
+function submit_form(action, src, target, ajax){
 
     if (openobject.http.AJAX_COUNT > 0) {
         callLater(1, submit_form, action, src, target);
@@ -245,8 +245,23 @@
     // action when creating an activity
     $form[0].setAttribute('action', action);
     $form.attr("target", target);
-    $form.submit();
-}
+    
+    if (ajax) {
+        jQuery.post(action, $form.serialize(),
+            function(data) {
+                $form.after(data);
+        });
+    } else {
+        $form.submit();
+    }
+    
+}
+
+
+function ajax_submit_form(action, src, target){
+	submit_form(action, src, target, true);
+}
+
 
 function pager_action(src){
     var $src = jQuery(src);