# HG changeset patch
# User Jorge Garcia <jorge.garcia@openbravo.com>
# Date 1501223941 -7200
#      Fri Jul 28 08:39:01 2017 +0200
# Node ID cb3ce7da643a81a55b8d94abd88677346fda3feb
# Parent  e192a021ea6db12180de23a26a7fb7a3e387c88a
Related to issue 36515: Improve BusinessPartner query performance removing location info from it

diff --git a/web/org.openbravo.mobile.core/source/data/ob-dal.js b/web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js
@@ -987,9 +987,11 @@
    * If the model is there it does nothing, if not it does an insert.
    */
   OB.Dal.saveIfNew = function (model, success, error) {
-    OB.Dal.get(OB.Model[model.modelName], model.get('id'), success, error, function () {
-      OB.Dal.save(model, success, error, true);
-    }, null, true);
+    OB.Dal.transaction(function (tx) {
+      OB.Dal.getInTransaction(tx, OB.Model[model.modelName], model.get('id'), success, error, function () {
+        OB.Dal.saveInTransaction(tx, model, success, error, true);
+      }, true);
+    });
   };
 
   OB.Dal.updateRecordColumn = function (record, columnName, newValue, successCallback, errorCallback) {
@@ -1194,8 +1196,8 @@
     }
   };
 
-  OB.Dal.getInTransaction = function (tx, model, id, success, error, empty) {
-    OB.Dal.get(model, id, success, error, empty, tx);
+  OB.Dal.getInTransaction = function (tx, model, id, success, error, empty, local) {
+    OB.Dal.get(model, id, success, error, empty, tx, local);
   };
 
   OB.Dal.get = function (model, id, success, error, empty, currentTransaction, local) {
