|
@@ -5,8 +5,7 @@ angular.module('odoo')
|
|
|
*/
|
|
|
.factory('leadsRemoteFactory', function (
|
|
|
leadsStorageFactory,
|
|
|
- customersRemoteFactory,
|
|
|
- customersStorageFactory,
|
|
|
+ depsRevolverFactory,
|
|
|
odooFactory,
|
|
|
sqlFactory,
|
|
|
asyncLoopFactory
|
|
@@ -38,10 +37,10 @@ angular.module('odoo')
|
|
|
*
|
|
|
*/
|
|
|
var push = function (id, data, success, error) {
|
|
|
- checkCustomer(data, function (customerRemoteId) {
|
|
|
+ depsRevolverFactory.checkCustomer(data, function (customerRemoteId) {
|
|
|
data.partner_id = customerRemoteId;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
delete data.id;
|
|
|
delete data.remote_id;
|
|
|
delete data.modified;
|
|
@@ -61,7 +60,7 @@ angular.module('odoo')
|
|
|
if (localDate > remoteDate) {
|
|
|
|
|
|
odooFactory.write('crm.lead', id, data, function (response) {
|
|
|
- console.log(response);
|
|
|
+ success(response);
|
|
|
}, function (odooErr) {
|
|
|
console.log(odooErr);
|
|
|
error(odooErr);
|
|
@@ -86,6 +85,7 @@ angular.module('odoo')
|
|
|
odooFactory.create('crm.lead', data, function (response) {
|
|
|
success(response);
|
|
|
}, function (odooErr) {
|
|
|
+ console.log(odooErr);
|
|
|
error(odooErr);
|
|
|
});
|
|
|
|
|
@@ -94,38 +94,7 @@ angular.module('odoo')
|
|
|
error(err);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- *
|
|
|
- */
|
|
|
- var checkCustomer = function (data, success, error) {
|
|
|
- if (data.partner_id == 0) {
|
|
|
- return success(0);
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory.selectById('partner', data.partner_id, function (row) {
|
|
|
- var customer = row.item(0);
|
|
|
-
|
|
|
- if (customer.partner_id == 0) {
|
|
|
- customersRemoteFactory.push(null, customer, function (remoteId) {
|
|
|
- customer.remote_id = remoteId;
|
|
|
-
|
|
|
- customersStorageFactory.save(customer, function (customerId) {
|
|
|
- success(remoteId);
|
|
|
- }, function (err) {
|
|
|
- error(err);
|
|
|
- });
|
|
|
- }, function (err) {
|
|
|
- error(err);
|
|
|
- });
|
|
|
- } else {
|
|
|
- success(customer.partner_id);
|
|
|
- }
|
|
|
- }, function (err) {
|
|
|
- error(err);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
*
|
|
|
*/
|
|
@@ -142,8 +111,8 @@ angular.module('odoo')
|
|
|
|
|
|
*
|
|
|
*/
|
|
|
- var get = function (contraint, success, error) {
|
|
|
- sqlFactory.selectByConstraint('crm_lead', contraint, function (leads) {
|
|
|
+ var get = function (constraint, success, error) {
|
|
|
+ sqlFactory.selectByConstraint('crm_lead', constraint, function (leads) {
|
|
|
success(leads);
|
|
|
}, function (err) {
|
|
|
error(err);
|
|
@@ -231,12 +200,20 @@ angular.module('odoo')
|
|
|
data.remote_id = data.id;
|
|
|
delete data.id;
|
|
|
|
|
|
- leadsStorageFactory.save(data, function (leadId) {
|
|
|
- loop.next();
|
|
|
- }, function (saveErr) {
|
|
|
+ depsRevolverFactory.resolveCustomer(data.partner_id, function (customerId) {
|
|
|
+ data.partner_id = customerId;
|
|
|
+
|
|
|
+ leadsStorageFactory.save(data, function (leadId) {
|
|
|
+ data.id = leadId;
|
|
|
+ loop.next();
|
|
|
+ }, function (saveErr) {
|
|
|
+ console.log(saveErr);
|
|
|
+ loop.next();
|
|
|
+ });
|
|
|
+ }, function (err) {
|
|
|
loop.next();
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}, function () {
|
|
|
success(leads);
|
|
@@ -262,7 +239,7 @@ angular.module('odoo')
|
|
|
|
|
|
console.log("leads --> updated data ok");
|
|
|
syncDeletedData(function () {
|
|
|
-
|
|
|
+
|
|
|
console.log("leads -> deleted data ok");
|
|
|
downloadSyncData(function (data) {
|
|
|
|