|
@@ -53,10 +53,14 @@ function report_stock_original (reporting){
|
|
|
},
|
|
|
submitForm: function(){
|
|
|
var self = this;
|
|
|
- self.fecthStockLocation().then(function(StockLocation){
|
|
|
- self.StockLocation=StockLocation;
|
|
|
- return StockLocation;
|
|
|
+ self.fecthProductProduct.then(function(productProduct){
|
|
|
+ self.productProduct=productProduct;
|
|
|
+ return productProduct;
|
|
|
+ }).then(function (productProduct){
|
|
|
+ self.productProduct = productProduct;
|
|
|
+ return self.fecthStockLocation();
|
|
|
}).then(function(StockLocation){
|
|
|
+ self.StockLocation = StockLocation;
|
|
|
self.$el.find('#current-location').append('<option value="9999999">Todas las Ubicación.</option>');
|
|
|
_.each(StockLocation,function(item){
|
|
|
self.$el.find('#current-location').append('<option value="' + item.id + '">' + item.location_id[1]+" / "+item.name + '</option>');
|
|
@@ -64,9 +68,6 @@ function report_stock_original (reporting){
|
|
|
return self.fecthStockQuant();
|
|
|
}).then(function(StockQuant){
|
|
|
self.StockQuant = StockQuant;
|
|
|
- return self.fecthProductProduct(StockQuant);
|
|
|
- }).then(function(productProduct){
|
|
|
- self.productProduct = productProduct;
|
|
|
return self.fecthProductCategory();
|
|
|
}).then(function(ProductCategory){
|
|
|
self.ProductCategory = ProductCategory;
|
|
@@ -78,6 +79,17 @@ function report_stock_original (reporting){
|
|
|
return self.BuildTable(self.StockQuant, self.StockLocation);
|
|
|
});
|
|
|
},
|
|
|
+ fecthProductProduct: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var fields = ['id','name','name_template', 'standard_price','type','attribute_value_ids', 'lst_price','ean13','categ_id','attribute_str'];
|
|
|
+ var productProduct = new instance.web.Model('product.product');
|
|
|
+ productProduct.query(fields).filter(['active', '=', true]).all().then(function (results) {
|
|
|
+ defer.resolve(results)
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
fecthStockLocation : function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
@@ -89,6 +101,7 @@ function report_stock_original (reporting){
|
|
|
})
|
|
|
return defer;
|
|
|
},
|
|
|
+
|
|
|
fecthStockQuant : function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
@@ -106,19 +119,7 @@ function report_stock_original (reporting){
|
|
|
})
|
|
|
return defer;
|
|
|
},
|
|
|
- fecthProductProduct: function(quant){
|
|
|
- var self = this;
|
|
|
- var defer = $.Deferred();
|
|
|
- var ids = _.flatten(_.map(quant, function (item) {
|
|
|
- return item.product_id[0];
|
|
|
- }));
|
|
|
- var fields = ['id','name','name_template', 'standard_price','type','attribute_value_ids', 'lst_price','ean13','categ_id','attribute_str'];
|
|
|
- var productProduct = new instance.web.Model('product.product');
|
|
|
- productProduct.query(fields).filter([['id', 'in', ids]]).all().then(function (results) {
|
|
|
- defer.resolve(results)
|
|
|
- });
|
|
|
- return defer;
|
|
|
- },
|
|
|
+
|
|
|
fecthProductCategory: function(){
|
|
|
var self = this;
|
|
|
var defer = $.Deferred();
|
|
@@ -189,14 +190,14 @@ function report_stock_original (reporting){
|
|
|
var total=0;
|
|
|
var cat = 0;
|
|
|
var quant;
|
|
|
- for (var i = 0; i < StockLocation.length; i++) {
|
|
|
- itemLocation = StockLocation[i];
|
|
|
- ProductProduct = self.getProdcutoProduct(self.productProduct, self.StockQuant, itemLocation.id);
|
|
|
+ // for (var i = 0; i < StockLocation.length; i++) {
|
|
|
+ // itemLocation = StockLocation[i];
|
|
|
+ // ProductProduct = self.getProdcutoProduct(self.productProduct, self.StockQuant, itemLocation.id);
|
|
|
// console.log(ProductProduct);
|
|
|
- for (var f = 0; f < ProductProduct.length; f++) {
|
|
|
- itemProduct = ProductProduct[f];
|
|
|
- //console.log(itemProduct);
|
|
|
- itemQuant = self.getQuantProduct(itemLocation.id, itemProduct.id, StockQuant);
|
|
|
+
|
|
|
+ _.each(self.ProductProduct, function(item){
|
|
|
+
|
|
|
+
|
|
|
// console.log(itemQuant);
|
|
|
// if (itemQuant.length = 0){
|
|
|
// itemQuant={};
|
|
@@ -226,23 +227,16 @@ function report_stock_original (reporting){
|
|
|
return mamo + num;
|
|
|
},0);
|
|
|
product = itemQuant.shift();
|
|
|
- total = parseInt(quantity * itemProduct.standard_price);
|
|
|
+
|
|
|
data.push({
|
|
|
id : product.product_id[0],
|
|
|
product : product.product_id[1],
|
|
|
ean13 : self.valorNull(itemProduct.ean13),
|
|
|
category_name : itemProduct.categ_id[1],
|
|
|
- qty : accounting.formatNumber(quantity,2, ".", ","),
|
|
|
- standard_price : accounting.formatNumber(itemProduct.standard_price,0, ".", ","),
|
|
|
- lst_price : accounting.formatNumber(itemProduct.lst_price,0, ".", ","),
|
|
|
- valuation: accounting.formatNumber(total,0,".",","),
|
|
|
- category_id : itemProduct.categ_id[0],
|
|
|
- location_id : product.location_id[0],
|
|
|
- location_name: product.location_id[1],
|
|
|
- total : total
|
|
|
+ qty : accounting.formatNumber(quantity,2, ".", ",")
|
|
|
});
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
self.content = data;
|