Ver Fonte

funcionalidad corregida en los atributos de productos

robert2206 há 8 anos atrás
pai
commit
af67d8e42a

+ 2 - 2
src/models/product.ts

@@ -12,7 +12,7 @@ export class Product {
     public rental: boolean;
     public sale_ok: boolean;
     public standard_price: number;
-    public type: number;
+    public type: string;
     public website_published: false;
     public remote_id: number;
     public doc_state: string;
@@ -31,7 +31,7 @@ export class Product {
         this.qty_available = 0;
         this.rental = false;
         this.standard_price = 1;
-        this.type = 0;
+        this.type = "product";
         this.website_published = false;
         this.remote_id = 0;
         this.doc_state = "created";

+ 2 - 9
src/pages/product-details/product-details.ts

@@ -163,20 +163,13 @@ export class ProductDetailsPage {
         })[0];
 
         attribute_line.value_ids = attribute_values;
+        attribute_line.doc_state = "updated";
         
-
-        // this.data.get(DataProvider.DOCS.PRODUCT_ATTRIBUTE_LINE, attribute_line.id).then(instance => { 
-        //     console.log(instance);
-            
-        // }).catch(e => { 
-        //     console.log(e);
-            
-        // });
         this.data.save(DataProvider.DOCS.PRODUCT_ATTRIBUTE_LINE, attribute_line).then(pal => { 
             console.log(pal);           
         }, e => { 
             this.toastCtrl.create({
-                message: 'No se han podido guardar los cambios',
+                message: "No se han podido guardar los cambios",
                 duration: 3000
             }).present();
         });

+ 4 - 2
src/pages/product-list/product-list.ts

@@ -126,9 +126,11 @@ export class ProductListPage extends DefaultListable<Product> implements INaviga
     removeItem(item: any) {
         item.doc_state = "deleted";
         
-        this.dataProvider.delete("product_template", item).then(result => {
+        this.dataProvider.delete(DataProvider.DOCS.PRODUCT_TEMPLATE, item).then(result => {
             this.remove(item);
-        }).catch(() => {
+        }).catch(e => {
+            console.log(e);
+            
             this.toastCtrl.create({
                 message: "No se pudo eliminar el producto",
                 duration: 3000

+ 1 - 1
src/providers/data-provider.ts

@@ -160,7 +160,7 @@ export class DataProvider {
     deleteAll(type: string): Promise<any> {
         return new Promise((resolve, reject) => { 
             this.getAll(type).then(data => {
-                each(data[type], (i, c) => { 
+                each(data, (i, c) => { 
                     this.db.rel.del(type, i).then(r => {
                         c();
                     }).catch(e => {

+ 1 - 1
src/providers/sync/product-attribute-line-sync-provider.ts

@@ -19,7 +19,7 @@ export class ProductAttributeLineSyncProvider {
             this.getUpdatedLines().then(lines => { 
                 return lines;
             }).then(lines => {
-                return this.odooProvider.post('product_attribute_line', lines);
+                return this.odooProvider.put('product_attribute_line', lines);
             }).then(response => {
                 console.log('product_attribute_line: product attribute lines modified sended');
                 return this.odooProvider.get('product_attribute_line');

+ 4 - 5
src/providers/sync/product-template-sync-provider.ts

@@ -23,8 +23,10 @@ export class ProductTemplateSyncProvider {
                 console.log('product_template: new products sended');    
                 return this.getUpdatedProducts();
             }).then(products => {
+                console.log(products);
+                    
                 return this.odooProvider.put("product_template", products);
-            }).then(() => {
+            }).then(response => {
                 console.log('product_template: modified products sended');   
                 return this.getDeletedProducts();
             }).then(products => {
@@ -67,7 +69,7 @@ export class ProductTemplateSyncProvider {
                 let products = templates.filter(item => {
                     return item.doc_state === "updated" && item.remote_id;
                 });
-                
+
                 resolve(products.map(item => {
                     delete item.id;
                     return item;
@@ -106,9 +108,6 @@ export class ProductTemplateSyncProvider {
             this.dataProvider.deleteAll(DataProvider.DOCS.PRODUCT_TEMPLATE).then(() => {
                 return;
             }).then(() => {
-                console.log(products);
-                
-                
                 return this.dataProvider.save(DataProvider.DOCS.PRODUCT_TEMPLATE, products.map(item => {
                     item.remote_id = item.id;
                     item.doc_state = "sync";

+ 1 - 1
src/providers/token-service.ts

@@ -12,7 +12,7 @@ import 'rxjs/add/observable/throw'
 export class TokenService {
 
     username: string = 'admin';
-    password: string = 'setlos/16';
+    password: string = 'admin';
     url: string = 'http://192.168.88.123:8069';
 
     constructor(