Browse Source

README.md added

robert 8 years ago
parent
commit
5a26883b65

+ 16 - 0
README.md

@@ -0,0 +1,16 @@
+                        Line Count Report 23/08/2016
+-------------------------------------------------------------------------------                                                                                
+Language                     files          blank        comment           code                                                                                
+-------------------------------------------------------------------------------                                                                                
+JavaScript                      81          19471          63483          86820                                                                                
+CSS                             10           2981            896          16192                                                                                
+SASS                            41           1151            321           8903                                                                                
+CoffeeScript                    13           1046             37           3776                                                                                
+Markdown                        20            557              0           1858                                                                                
+JSON                            32              0              0            966                                                                                
+HTML                            14             58             18            452                                                                                
+TypeScript                       1             14             18             94                                                                                
+YAML                             2              5              0             24                                                                                
+-------------------------------------------------------------------------------                                                                                
+SUM:                           214          25283          64773         119085                                                                                
+-------------------------------------------------------------------------------  

+ 6 - 1
www/js/controllers/configuration.controller.js

@@ -1,5 +1,8 @@
 angular.module('odoo')
 
+    /**
+     *
+     */
     .controller('ConfigurationController', function (
         $scope,
         $state,
@@ -19,7 +22,9 @@ angular.module('odoo')
             id: null
         });
 
-        // Auth app
+        /**
+         *
+         */
         $scope.auth = function () {
             $scope.loading = true;
 

+ 6 - 3
www/js/factories/database.factory.js

@@ -3,7 +3,10 @@ angular.module('odoo')
     /**
      *
      */
-    .factory('databaseFactory', function ($localStorage, odooFactory, asyncLoopFactory) {
+    .factory('databaseFactory', function (
+        odooFactory,
+        asyncLoopFactory
+    ) {
 
         var mappings = [
             {
@@ -58,11 +61,11 @@ angular.module('odoo')
          */
         var fetchMaps = function (success, error) {
             var maps = [];
-            console.log($localStorage);
+
             asyncLoopFactory(mappings.length, function (loop) {
                 var map = mappings[loop.iteration()];
 
-                odooFactory.fields(map.model, $localStorage, function (response) {
+                odooFactory.fields(map.model, function (response) {
                     maps.push({ table: map.table, model: response });
 
                     loop.next();

+ 125 - 78
www/js/factories/odoo.factory.js

@@ -1,87 +1,134 @@
 angular.module('odoo')
 
-    .factory('odooFactory', function (xmlrpc, methodCallManager) {
+    /**
+     *
+     */
+    .factory('odooFactory', function (
+        $localStorage,
+        xmlrpc,
+        methodCallManager
+    ) {
+        var configuration = $localStorage;
+
+        /**
+         *
+         */
+        var auth = function (success, error) {
+            xmlrpc.callMethod(methodCallManager.call('authenticate', configuration), [configuration.database, configuration.username, configuration.password, {}]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var read = function (model, domain, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'search_read', [domain]]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var create = function (model, data, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'create', [data]]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var write = function (model, id, data, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'write', [[id], data]]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var unlink = function (model, id, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'unlink', [[id]]]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var check = function (model, operation, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'check_access_rights', [operation], { 'raise_exception': false }]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
+        /**
+         *
+         */
+        var fields = function (model, success, error) {
+            xmlrpc.callMethod(methodCallManager.call('execute_kw', configuration), [configuration.database, configuration.id, configuration.password, model, 'fields_get', [], { 'attributes': ['type', 'readonly', 'required', 'relation', 'relation_field'] }]).then(function (response) {
+                if (!response || response['faultCode']) {
+                    return error(response);
+                }
+
+                success(response);
+            }, function (xmlrpcError) {
+                error(xmlrpcError);
+            });
+        }
+
         return {
-            auth: function (config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('authenticate', config), [config.database, config.username, config.password, {}]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            read: function (model, domain, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'search_read', [domain]]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            create: function (model, data, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'create', [data]]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            write: function (model, id, data, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'write', [[id], data]]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            unlink: function (model, id, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'unlink', [[id]]]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            check: function (model, operation, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'check_access_rights', [operation], { 'raise_exception': false }]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            },
-            fields: function (model, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'fields_get', [], { 'attributes': ['type', 'readonly', 'required', 'relation', 'relation_field'] }]).then(function (response) {
-                    if (!response || response['faultCode']) {
-                        return error(response);
-                    }
-
-                    success(response);
-                }, function (xmlrpcError) {
-                    error(xmlrpcError);
-                });
-            }
+            auth: auth,
+            read: read,
+            create: create,
+            write: write,
+            unlink: unlink,
+            check: check,
+            fields: fields
         }
     })
 
+    /**
+     *
+     */
     .factory('methodCallManager', function (xmlrpc) {
         return {
             call: function (methodName, configuration) {

+ 1 - 1
www/js/factories/sales/crm.stage.storage.factory.js

@@ -30,7 +30,7 @@ angular.module('odoo')
             query = query.toParam();
 
             db.executeSql(query.text(), query.values, function (result) {
-                success(query.text.startsWith('INSERT') ? result.insertId : lead.id);
+                success(query.text.startsWith('INSERT') ? result.insertId : data.id);
             }, function (err) {
                 error(err);
             });

+ 22 - 27
www/js/factories/sales/crm.stage.sync.factory.js

@@ -8,36 +8,31 @@ angular.module('odoo')
     .factory('crmStagesDataFactory', function (
         crmStagesStorageFactory,
         odooFactory,
-        configFactory,
         sqlFactory,
         asyncLoopFactory
     ) {
-        
+
         /**
          *
          */
         var pull = function (id, success, error) {
-            configFactory(function (configuration) {
-                if (id) {
+            if (id) {
 
-                    odooFactory.read('crm.case.stage', [['id', '=', id]], configuration, function (response) {
-                        success(response);
-                    }, function (odooErr) {
-                        error(odooErr);
-                    });
+                odooFactory.read('crm.case.stage', [['id', '=', id]], function (response) {
+                    success(response);
+                }, function (odooErr) {
+                    error(odooErr);
+                });
 
-                } else {
-                    
-                    odooFactory.read('crm.case.stage', [], configuration, function (response) {
-                        success(response);
-                    }, function (odooErr) {
-                        error(odooErr)
-                    });
+            } else {
 
-                }
-            }, function (configErr) {
-                error(configErr);
-            });
+                odooFactory.read('crm.case.stage', [], function (response) {
+                    success(response);
+                }, function (odooErr) {
+                    error(odooErr)
+                });
+
+            }
         }
 
         /**
@@ -45,8 +40,8 @@ angular.module('odoo')
          */
         var push = function (id, data, success, error) {
             // TODO
-        }   
-        
+        }
+
         /**
          *
          */
@@ -75,8 +70,8 @@ angular.module('odoo')
          *
          */
         var sync = function (success, error) {
-            pull(0, function (stages) { 
-                crmStagesStorageFactory.removeAll(function () { 
+            pull(0, function (stages) {
+                crmStagesStorageFactory.removeAll(function () {
                     asyncLoopFactory(stages.length, function (loop) {
                         var data = stages[loop.iteration()];
 
@@ -89,15 +84,15 @@ angular.module('odoo')
                             console.log(saveErr);
                             loop.next();
                         });
-                        
-                    // End loop
+
+                        // end loop
                     }, function () {
                         success(stages);
                     });
                 }, function (removeAllErr) {
                     error(removeAllErr);
                 });
-            }, function (pullErr) { 
+            }, function (pullErr) {
                 error(pullErr);
             });
         }

+ 156 - 149
www/js/factories/sales/customer.sync.factory.js

@@ -1,19 +1,22 @@
 angular.module('odoo')
 
-.factory('customersRemoteFactory', function (
-    customersStorageFactory,
-    odooFactory,
-    configFactory,
-    sqlFactory,
-    asyncLoopFactory
-) {
-
-    // Pull server customers data
-    var pull = function (id, success, error) {
-        configFactory(function (configuration) {
+    /**
+     *
+     */
+    .factory('customersRemoteFactory', function (
+        customersStorageFactory,
+        odooFactory,
+        sqlFactory,
+        asyncLoopFactory
+    ) {
+
+        /**
+         *
+         */
+        var pull = function (id, success, error) {
             if (id) {
 
-                odooFactory.read('res.partner', [['id', '=', id]], configuration, function (response) {
+                odooFactory.read('res.partner', [['id', '=', id]], function (response) {
                     success(response);
                 }, function (odooErr) {
                     error(odooErr);
@@ -21,27 +24,25 @@ angular.module('odoo')
 
             } else {
 
-                odooFactory.read('res.partner', [['customer', '=', true]], configuration, function (response) {
+                odooFactory.read('res.partner', [['customer', '=', true]], function (response) {
                     success(response);
                 }, function (odooErr) {
                     error(odooErr)
                 });
 
             }
-        }, function (configErr) {
-            error(configErr);
-        });
-    }
+        }
 
-    // Push customers data to server
-    var push = function (id, data, success, error) {
+        /**
+         *
+         */
+        var push = function (id, data, success, error) {
 
-        // Avoid odoo server warning message
-        delete data.id;
-        delete data.remote_id;
-        delete data.modified;
+            // Avoid odoo server warning message
+            delete data.id;
+            delete data.remote_id;
+            delete data.modified;
 
-        configFactory(function (configuration) {
             if (id) {
 
                 pull(id, function (response) {
@@ -55,7 +56,7 @@ angular.module('odoo')
 
                         if (localDate > remoteDate) {
 
-                            odooFactory.write('res.partner', id, data, configuration, function (response) {
+                            odooFactory.write('res.partner', id, data, function (response) {
                                 success(response);
                             }, function (odooErr) {
                                 error(odooErr);
@@ -77,149 +78,158 @@ angular.module('odoo')
 
                 delete data.modifiedDate;
 
-                odooFactory.create('res.partner', data, configuration, function (response) {
+                odooFactory.create('res.partner', data, function (response) {
                     success(response);
                 }, function (odooErr) {
                     error(odooErr);
                 });
 
             }
-        }, function (configFactoryErr) {
-            error(configFactoryErr);
-        });
-    }
+        }
 
-    // Destroy server customer data
-    var destroy = function(id, success, error) {
-        configFactory(function (configuration) {
+        /**
+         *
+         */
+        var destroy = function (id, success, error) {
 
-            odooFactory.unlink('res.partner', id, configuration, function (response) {
+            odooFactory.unlink('res.partner', id, function (response) {
                 success(response);
             }, function (odooInteroperabilityFactoryErr) {
                 error(odooInteroperabilityFactoryErr);
             });
+        }
+
+        /**
+         *
+         */
+        var get = function (constraint, success, error) {
+            sqlFactory.selectByConstraint('partner', constraint, function (customers) {
+                success(customers);
+            }, function (err) {
+                error(err);
+            });
+        }
 
-        }, function (configFactoryErr) {
-            error(configFactoryErr);
-        });
-    }
-
-    // Get local customer data
-    var get = function (constraint, success, error) {
-        sqlFactory.selectByConstraint('partner', constraint, function (customers) {
-            success(customers);
-        }, function (err) {
-            error(err);
-        });
-    }
-
-
-    // Send all new data from local to remote server
-    var syncNewData = function (success, error) {
-        get('remote_id = 0 AND customer = 1', function (newCustomers) {
-            asyncLoopFactory(newCustomers.length, function (loop) {
-                var data = newCustomers.item(loop.iteration());
-
-                push(null, data, function (response) {
-                    loop.next();
-                }, function (pushErr) {
-                    loop.break();
-                });
 
-            // End loop
-            }, function () {
-                success(newCustomers);
-            });
-        }, function (getErr) {
-            error(getErr);
-        });
-    }
-
-    // Update all data from server
-    var syncUpdatedData = function (success, error) {
-        get('remote_id != 0 AND customer = 1 AND modified = 1', function (updatedCustomers) {
-            asyncLoopFactory(updatedCustomers.length, function (loop) {
-                var data = updatedCustomers.item(loop.iteration());
-
-                push(data.remote_id, data, function (response) {
-                    loop.next();
+        /**
+         *
+         */
+        var syncNewData = function (success, error) {
+            get('remote_id = 0 AND customer = 1', function (newCustomers) {
+                asyncLoopFactory(newCustomers.length, function (loop) {
+                    var data = newCustomers.item(loop.iteration());
+
+                    push(null, data, function (response) {
+                        loop.next();
+                    }, function (pushErr) {
+                        loop.break();
+                    });
+
+                    // end loop
                 }, function () {
-                    loop.next();
+                    success(newCustomers);
                 });
-
-            // End loop
-            }, function () {
-                success(updatedCustomers);
+            }, function (getErr) {
+                error(getErr);
             });
-        }, function (getErr) {
-            error(getErr);
-        });
-    }
-
-    // Delete all data
-    var syncDeletedData = function (success, error) {
-        get('remote_id != 0 AND customer = 1 AND modified = 2', function (deletedCustomers) {
-            asyncLoopFactory(deletedCustomers.length, function (loop) {
-                var id = deletedCustomers.item(loop.iteration()).remote_id;
-
-                destroy(id, function (response) {
-                    loop.next();
-                }, function (destroyErr) {
-                    loop.next();
-                });
+        }
 
-            // End loop
-            }, function () {
-                success(deletedCustomers);
-            });
-        }, function(getErr) {
-            error(getErr);
-        });
-    }
-
-    // Download all sync data from server
-    var downloadSyncData = function (success, error) {
-        pull(null, function (customers) {
-            console.log(customers);
-            customersStorageFactory.removeAll(function () {
-                asyncLoopFactory(customers.length, function (loop) {
-                    var data = customers[loop.iteration()];
-
-                    data.remote_id = data.id;
-                    delete data.id;
-
-                    customersStorageFactory.save(data, function (customerId) {
+        /**
+         *
+         */
+        var syncUpdatedData = function (success, error) {
+            get('remote_id != 0 AND customer = 1 AND modified = 1', function (updatedCustomers) {
+                asyncLoopFactory(updatedCustomers.length, function (loop) {
+                    var data = updatedCustomers.item(loop.iteration());
+
+                    push(data.remote_id, data, function (response) {
                         loop.next();
-                    }, function (saveErr) {
+                    }, function () {
                         loop.next();
                     });
 
-                // End loop
+                    // End loop
                 }, function () {
-                    success(customers);
+                    success(updatedCustomers);
                 });
+            }, function (getErr) {
+                error(getErr);
+            });
+        }
 
-            }, function (removeAllErr) {
-                error(removeAllErr);
+        /**
+         *
+         */
+        var syncDeletedData = function (success, error) {
+            get('remote_id != 0 AND customer = 1 AND modified = 2', function (deletedCustomers) {
+                asyncLoopFactory(deletedCustomers.length, function (loop) {
+                    var id = deletedCustomers.item(loop.iteration()).remote_id;
+
+                    destroy(id, function (response) {
+                        loop.next();
+                    }, function (destroyErr) {
+                        loop.next();
+                    });
+
+                    // end loop
+                }, function () {
+                    success(deletedCustomers);
+                });
+            }, function (getErr) {
+                error(getErr);
             });
+        }
+
+        /**
+         *
+         */
+        var downloadSyncData = function (success, error) {
+            pull(null, function (customers) {
+  
+                customersStorageFactory.removeAll(function () {
+                    asyncLoopFactory(customers.length, function (loop) {
+                        var data = customers[loop.iteration()];
+
+                        data.remote_id = data.id;
+                        delete data.id;
+
+                        customersStorageFactory.save(data, function (customerId) {
+                            loop.next();
+                        }, function (saveErr) {
+                            loop.next();
+                        });
+
+                        // End loop
+                    }, function () {
+                        success(customers);
+                    });
 
-        }, function (pullErr) {
-            error(pullErr);
-        });
-    }
+                }, function (removeAllErr) {
+                    error(removeAllErr);
+                });
+
+            }, function (pullErr) {
+                error(pullErr);
+            });
+        }
 
-    // Sync customers data between remote and local storage
-    var sync = function (success, error) {
-        syncNewData(function () {
+        /**
+         *
+         */
+        var sync = function (success, error) {
+            syncNewData(function () {
 
-            syncUpdatedData(function () {
+                syncUpdatedData(function () {
 
-                syncDeletedData(function () {
+                    syncDeletedData(function () {
 
-                    downloadSyncData(function (data) {
-                        success(data);
-                    }, function (downloadErr) {
-                        error(downloadErr);
+                        downloadSyncData(function (data) {
+                            success(data);
+                        }, function (downloadErr) {
+                            error(downloadErr);
+                        });
+                    }, function (syncErr) {
+                        error(syncErr);
                     });
                 }, function (syncErr) {
                     error(syncErr);
@@ -227,15 +237,12 @@ angular.module('odoo')
             }, function (syncErr) {
                 error(syncErr);
             });
-        }, function (syncErr) {
-            error(syncErr);
-        });
-    }
-
-    return {
-        pull: pull,
-        push: push,
-        destroy: destroy,
-        sync: sync
-    }
-});
+        }
+
+        return {
+            pull: pull,
+            push: push,
+            destroy: destroy,
+            sync: sync
+        }
+    });

+ 79 - 73
www/js/factories/sales/lead.sync.factory.js

@@ -1,39 +1,41 @@
 angular.module('odoo')
 
+    /**
+     *
+     */
     .factory('leadsRemoteFactory', function (
         leadsStorageFactory,
         odooFactory,
-        configFactory,
         sqlFactory,
         asyncLoopFactory
     ) {
 
-        // Pull server leads data
+        /**
+         *
+         */
         var pull = function (id, success, error) {
-            configFactory(function (configuration) {
-                if (id) {
+            if (id) {
 
-                    odooFactory.read('crm.lead', [['id', '=', id]], configuration, function (response) {
-                        success(response);
-                    }, function (odooErr) {
-                        error(odooErr)
-                    });
+                odooFactory.read('crm.lead', [['id', '=', id]], function (response) {
+                    success(response);
+                }, function (odooErr) {
+                    error(odooErr)
+                });
 
-                } else {
+            } else {
 
-                    odooFactory.read('crm.lead', [['type', '=', 'lead']], configuration, function (response) {
-                        success(response);
-                    }, function (odooErr) {
-                        error(odooErr);
-                    });
+                odooFactory.read('crm.lead', [['type', '=', 'lead']], function (response) {
+                    success(response);
+                }, function (odooErr) {
+                    error(odooErr);
+                });
 
-                }
-            }, function (configErr) {
-                error(configErr);
-            });
+            }
         }
 
-        // Push leads data to server
+        /**
+         *
+         */
         var push = function (id, data, success, error) {
 
             // Avoid odoo server warning message
@@ -42,74 +44,68 @@ angular.module('odoo')
             delete data.modified;
             delete data.priority;
 
-            configFactory(function (configuration) {
-
-                if (id) {
-
-                    pull(id, function (response) {
-                        if (response.length == 1) {
-                            var remoteData = response[0];
+            if (id) {
 
-                            var remoteDate = new Date(remoteData.__last_update);
-                            var localDate = new Date(data.modifiedDate);
+                pull(id, function (response) {
+                    if (response.length == 1) {
+                        var remoteData = response[0];
 
-                            delete data.modifiedDate;
+                        var remoteDate = new Date(remoteData.__last_update);
+                        var localDate = new Date(data.modifiedDate);
 
-                            if (localDate > remoteDate) {
+                        delete data.modifiedDate;
 
-                                odooFactory.write('crm.lead', id, data, configuration, function (response) {
-                                    console.log(response);
-                                    success(response);
-                                }, function (odooErr) {
-                                    console.log(odooErr);
-                                    error(odooErr);
-                                });
+                        if (localDate > remoteDate) {
 
-                            } else {
+                            odooFactory.write('crm.lead', id, data, function (response) {
+                                console.log(response);
                                 success(response);
-                            }
+                            }, function (odooErr) {
+                                console.log(odooErr);
+                                error(odooErr);
+                            });
 
                         } else {
                             success(response);
                         }
 
-                    }, function (pullErr) {
-                        error(pullErr);
-                    });
-
-                } else {
-
-                    delete data.modifiedDate;
-
-                    odooFactory.create('crm.lead', data, configuration, function (response) {
+                    } else {
                         success(response);
-                    }, function (odooErr) {
-                        error(odooErr);
-                    });
+                    }
 
-                }
+                }, function (pullErr) {
+                    error(pullErr);
+                });
 
-            }, function (configErr) {
-                error(configErr);
-            });
-        }
+            } else {
 
-        // Destroy server lead data
-        var destroy = function (id, success, error) {
-            configFactory(function (configuration) {
+                delete data.modifiedDate;
 
-                odooFactory.unlink('crm.lead', id, configuration, function (response) {
+                odooFactory.create('crm.lead', data, function (response) {
                     success(response);
                 }, function (odooErr) {
                     error(odooErr);
                 });
 
-            }, function (configErr) {
-                error(configErr);
+            }
+        }
+
+        /**
+         *
+         */
+        var destroy = function (id, success, error) {
+
+            odooFactory.unlink('crm.lead', id, function (response) {
+                success(response);
+            }, function (odooErr) {
+                error(odooErr);
             });
+
         }
 
-        // Get local lead data
+        /**
+         *
+         */
         var get = function (contraint, success, error) {
             sqlFactory.selectByConstraint('lead', contraint, function (leads) {
                 success(leads);
@@ -118,7 +114,9 @@ angular.module('odoo')
             });
         }
 
-        // Send all new data from local to remote server
+        /**
+         *
+         */
         var syncNewData = function (success, error) {
             get('remote_id = 0', function (newLeads) {
                 asyncLoopFactory(newLeads.length, function (loop) {
@@ -130,7 +128,7 @@ angular.module('odoo')
                         loop.next();
                     });
 
-                    // End loop
+                    // end loop
                 }, function () {
                     success(newLeads);
                 });
@@ -139,7 +137,9 @@ angular.module('odoo')
             });
         }
 
-        // Update all data from server
+        /**
+         *
+         */
         var syncUpdatedData = function (success, error) {
             get("remote_id != 0 AND modified = 1", function (updatedLeads) {
                 asyncLoopFactory(updatedLeads.length, function (loop) {
@@ -153,7 +153,7 @@ angular.module('odoo')
                         loop.next();
                     });
 
-                    // End loop
+                    // end loop
                 }, function () {
                     success(updatedLeads);
                 });
@@ -162,7 +162,9 @@ angular.module('odoo')
             });
         }
 
-        // Delete all data
+        /**
+         *
+         */
         var syncDeletedData = function (success, error) {
             get('remote_id != 0 AND modified = 2', function (deletedLeads) {
                 asyncLoopFactory(deletedLeads.length, function (loop) {
@@ -174,7 +176,7 @@ angular.module('odoo')
                         loop.next();
                     });
 
-                    // End loop
+                    // end loop
                 }, function () {
                     success(deletedLeads);
                 });
@@ -183,7 +185,9 @@ angular.module('odoo')
             });
         }
 
-        // Download all sync data from server
+        /**
+         *
+         */
         var downloadSyncData = function (success, error) {
             pull(null, function (leads) {
 
@@ -200,7 +204,7 @@ angular.module('odoo')
                             loop.next();
                         });
 
-                        // End loop
+                        // end loop
                     }, function () {
                         success(leads);
                     });
@@ -214,7 +218,9 @@ angular.module('odoo')
             });
         }
 
-        // Sync all leads data between local and remote data
+        /**
+         *
+         */
         var sync = function (success, error) {
             syncNewData(function () {
 

+ 2 - 7
www/js/factories/sales/opportunity.sync.factory.js

@@ -9,7 +9,6 @@ angular.module('odoo')
         opportunitiesStorageFactory,
         leadsRemoteFactory,
         odooFactory,
-        configFactory,
         sqlFactory,
         asyncLoopFactory
     ) {
@@ -18,10 +17,9 @@ angular.module('odoo')
          *
          */
         var pull = function (id, success, error) {
-            configFactory(function (configuration) {
                 if (id) {
 
-                    odooFactory.read('crm.lead', [['id', '=', id]], configuration, function (response) {
+                    odooFactory.read('crm.lead', [['id', '=', id]], function (response) {
                         success(response);
                     }, function (odooErr) {
                         error(odooErr);
@@ -29,15 +27,12 @@ angular.module('odoo')
 
                 } else {
 
-                    odooFactory.read('crm.lead', [['type', '=', 'opportunity']], configuration, function (response) {
+                    odooFactory.read('crm.lead', [['type', '=', 'opportunity']], function (response) {
                         success(response);
                     }, function (odooErr) {
                         error(odooErr);
                     });
                 }
-            }, function (configErr) {
-                error(configErr);
-            });
         }
 
         /**