# HG changeset patch
# User Rafa Alonso <ral@openbravo.com>
# Date 1437987961 -7200
#      Mon Jul 27 11:06:01 2015 +0200
# Node ID 4c1e6054520b0c84886f70f9e5bac5e5748d564b
# Parent  a522db26b2f1344a17d96aca30736b65d5379675
Update only the 'isBeingProcessed' field when synchronized

diff -r a522db26b2f1 -r 4c1e6054520b web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
--- a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js	Tue Jul 21 11:52:21 2015 +0200
+++ b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js	Mon Jul 27 11:06:01 2015 +0200
@@ -734,9 +734,23 @@
             newDataToSync.each(function (record) {
               if (modelObj.isPersistent) {
                 // Persistent model. Do not delete, just mark it as processed.
-                record.set('isbeingprocessed', 'Y');
-                OB.Dal.save(record, null, function (tx, err) {
-                  OB.UTIL.showError(err);
+                var modelProto = record.constructor.prototype;
+                var modelDefinition = OB.Model[modelProto.modelName];
+                var tableName = OB.Dal.getTableName(modelDefinition);
+                var sql = "UPDATE " + tableName + " SET isbeingprocessed = ? WHERE " + tableName + "_id = ?";
+                var params = ['Y', record.get('id')];
+                OB.Data.localDB.transaction(function (tx) {
+                  try {
+                    tx.executeSql(sql, params, function () {
+                      // success
+                      OB.info("'isbeingprocessed' has been set to 'Y' in the '" + tableName + "' table, record id: " + record.get('id'));
+                    }, function (txError, e) {
+                      // error
+                      OB.error("'isbeingprocessed' has NOT been set to 'Y' in the '" + tableName + "' table, record id: " + record.get('id') + ". Error message: " + e.message);
+                    });
+                  } catch (e) {
+                    OB.error("cannot create a transaction for the '" + tableName + "' table, record id: " + record.get('id') + ". Error message: " + e);
+                  }
                 });
               } else {
                 // no persistent model (Default).
