# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1504004013 -7200
#      Tue Aug 29 12:53:33 2017 +0200
# Node ID d060f32d8896bacee6f3d7d666b6494ac4d5a6dc
# Parent  b90f916bbbd69e2ed37eef7f98a11f6e94e26932
Related to issue 36662. Added limit to avoid problems if model doesn't define a limit by default. Only refresh offline models.

diff -r b90f916bbbd6 -r d060f32d8896 web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js	Mon Aug 28 15:30:40 2017 +0200
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js	Tue Aug 29 12:53:33 2017 +0200
@@ -1507,7 +1507,9 @@
         return;
       }
 
-      OB.Dal.find(models[idx], {}, function () {
+      OB.Dal.find(models[idx], {
+        _limit: 100
+      }, function () {
         forceLocalDatabaseLoad(models, idx + 1, callback);
       }, function () {
         forceLocalDatabaseLoad(models, idx + 1, callback);
@@ -1603,7 +1605,9 @@
           if (incremental && OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName)) {
             timestamp = OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName);
           }
-          modelsInLocalDb.push(item);
+          if (!item.prototype.online) {
+            modelsInLocalDb.push(item);
+          }
           ds = new OB.DS.DataSource(new OB.DS.Request(item, timestamp));
           somethigToLoad = true;
           models._failedModels = models._failedModels || [];
