Ver Fonte

FIX ADD retoques en analisis e historico de ventas, pos y compras agregado filtros de variantes y categoria

Sebas há 6 anos atrás
pai
commit
eb6f0ae20d

+ 1 - 1
__openerp__.py

@@ -4,7 +4,7 @@
     'author': "Robert Gauto/Adrielso Kunert/Rodney Enciso Arias/Sebastian Penayo",
     'category': 'Uncategorized',
     'version': '0.1',
-    'depends': ['base','eiru_assets'],
+    'depends': ['base','eiru_assets','product'],
     'qweb': [
         'static/src/xml/*.xml',
         'static/src/reports/*.xml'

+ 30 - 3
models.py

@@ -2,7 +2,34 @@
 
 from openerp import models, fields, api
 
-# class eiru_reporting(models.Model):
-#     _name = 'eiru_reporting.eiru_reporting'
+class ProductProduct(models.Model):
+	_inherit = 'product.product'
 
-#     name = fields.Char()
+	@api.model
+	def getProductProduct(self,domain):
+		# import web_pdb; web_pdb.set_trace()
+		ProductProduct = self.env['product.product'].search(domain)
+		values = []
+		for product in ProductProduct:
+			# import web_pdb; web_pdb.set_trace()
+			attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
+			attributeIDS = []
+			for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
+				attributeIDS.append(arttIds.attribute_id.id)
+
+
+			values.append({
+				'id': product.id,
+				'name': product.name,
+				'standard_price': product.standard_price,
+				'ean13': product.ean13,
+				'categ_id': {
+					'id': product.categ_id.id,
+					'name': product.categ_id.name,
+					'complete_name': product.categ_id.complete_name,
+				},
+				'atribute_value_ids': attributeValuesLines,
+				'attribute_ids': attributeIDS
+			})
+
+		return values

BIN
models.pyc


+ 10 - 1
static/src/js/reports/ranking_pos_orders_product_cy.js

@@ -526,7 +526,16 @@ function ranking_pos_orders_product_cy (reporting) {
                         display: true,
                         text: 'Ranking de productos más vendidos'
                     }
-                }
+                },
+
+                 layout: {
+                     padding: {
+                         top: 0,
+                         bottom: 40,
+                         left: 0,
+                         rigth: 0,
+                     }
+                 }
             });
         },
         // llamar a la lista

+ 1 - 1
static/src/js/reports/report_pos.js

@@ -367,7 +367,7 @@ function report_pos(reporting){
                 $('#datepicker').css('display','block');
                 if (desde.length > 0){
                     var date= desde.split('/');
-                    console.log(date);
+
                     content = _.filter(content, function (inv){
                         return inv.date >= (date[2]+"-"+date[1]+"-"+date[0]);
                     });

+ 171 - 57
static/src/js/reports/report_pos_orders.js

@@ -6,6 +6,7 @@ function report_pos_orders(reporting){
     reporting.ReportPosOrdersWidget = reporting.Base.extend({
         template: 'ReportPosOrders',
         rowsData :[],
+        PosOrder :[],
         PosOrderLine: [],
         modules:[],
         content:[],
@@ -23,6 +24,8 @@ function report_pos_orders(reporting){
             'change #current-category' : 'fectSearch',
             'change #partner': 'fectSearch',
             'change #current-floor': 'fectSearch',
+            'change #current-attribute': 'fectSearch',
+            'change #current-attribute-value': 'fectSearch',
             'change #current-table': 'fectSearch',
             'change #current-store': 'fectSearch',
             'click-row.bs.table #table' : 'clickAnalysisDetail',
@@ -33,8 +36,9 @@ function report_pos_orders(reporting){
         },
 
         start: function () {
+            var self = this;
             var table = this.$el.find('#table');
-            table.bootstrapTable({data : self.rowData});
+            table.bootstrapTable({data : self.rowsData});
             this.fecthFecha();
             this.submitForm();
         },
@@ -172,18 +176,40 @@ function report_pos_orders(reporting){
                 return self.fetchPosOrderLine(PosOrder);
             }).then(function (PosOrderLine) {
                 self.PosOrderLine = PosOrderLine;
-                return self.fetchProductProduct(PosOrderLine);
+                return self.fetchProductProduct();
             }).then(function (ProductProduct) {
                 self.ProductProduct = ProductProduct;
+                return self.fetchProductAttribute();
+            }).then(function (ProductAttribute) {
+                self.ProductAttribute = ProductAttribute;
+                if(ProductAttribute.length > 0){
+                    self.$el.find('#current-attribute').append('<option value="9999999">Todos los atributos</option>');
+                    _.each(ProductAttribute,function(item){
+                        self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute').css('display','none');
+                }
+                return self.fetchProductAttributeValue();
+            }).then(function(ProductAttributeValue){
+                self.ProductAttributeValue = ProductAttributeValue;
+                if(ProductAttributeValue.length > 0){
+                    self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                    _.each(ProductAttributeValue,function(item){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute-value').css('display','none');
+                }
                 return self.fetchResPartner();
             }).then(function (ResPartner){
                 self.ResPartner = ResPartner;
-                return self.fecthPosCategory();
-            }).then(function(PosCategory){
-                self.PosCategory = PosCategory;
+                return self.fetchProductCategory();
+            }).then(function(ProductCategory){
+                self.ProductCategory = ProductCategory;
                 self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
-                _.each(PosCategory, function (item) {
-                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                _.each(ProductCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.complete_name + '</option>');
                 });
                 return self.fetchPosFloor();
             }).then(function(PosFloor){
@@ -281,7 +307,7 @@ function report_pos_orders(reporting){
             var fields = ['id', 'name', 'order_id', 'product_id', 'qty', 'price_unit', 'price_subtotal_incl']
             var domain = [['order_id', 'in', ids]];
             var PosOrderLine = new model.web.Model('pos.order.line');
-            PosOrderLine.query().filter(domain).all().then(function (results) {
+            PosOrderLine.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
             });
             return defer;
@@ -327,39 +353,59 @@ function report_pos_orders(reporting){
         },
 
         // Productos
-        fetchProductProduct: function(PosOrderLine){
+        fetchProductProduct: function(){
             var self = this;
-            var defer = $.Deferred();
-            var porduct_ids = _.flatten(_.map(PosOrderLine, function (item) {
+            var product_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
                 return item.product_id[0];
             }));
-            var fields = ['id','name', 'default_code', 'name_template','ean13','lst_price','pos_categ_id', 'standard_price','type','attribute_str'];
-            var domain = [['id', 'in', porduct_ids]];
-            var ProductProduct =  new model.web.Model('product.product');
-            ProductProduct.query(fields).filter(domain).all().then(function (results) {
+            var domain = [['id','in',product_ids]];
+            var ProductProduct = new model.web.Model('product.product');
+            return ProductProduct.call('getProductProduct',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        fetchProductCategory : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','parent_id','complete_name'];
+            var ProductCategory = new model.web.Model('product.category');
+            ProductCategory.query(fields).filter().all().then(function(results) {
                 defer.resolve(results);
             });
             return defer;
         },
 
-        fecthPosCategory: function(){
+        fetchProductAttribute : function(){
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name'];
-            var PosCategory =  new model.web.Model('pos.category');
-            PosCategory.query(fields).filter().all().then(function (results) {
-                defer.resolve(results)
+            var ProductAttribute = new model.web.Model('product.attribute');
+            ProductAttribute.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
             });
             return defer;
         },
 
+        fetchProductAttributeValue : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','attribute_id'];
+            var ProductAttributeValue = new model.web.Model('product.attribute.value');
+            ProductAttributeValue.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+
         // Mesa o delivery
         fetchPosTable: function(){
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'floor_id'];
-            var ProductProduct =  new model.web.Model('pos.table');
-            ProductProduct.query(fields).filter().all().then(function (results) {
+            var ProductPosTable =  new model.web.Model('pos.table');
+            ProductPosTable.query(fields).filter().all().then(function (results) {
                 defer.resolve(results);
             });
             return defer;
@@ -391,21 +437,6 @@ function report_pos_orders(reporting){
             });
         },
 
-        // Obtener las lineas de las Facturas
-        getProductProduct: function(pro_id){
-            var self = this;
-            return _.find(self.ProductProduct, function(prod){
-                return _.contains(pro_id, prod.id);
-            });
-        },
-
-
-        getPosCategory: function(id){
-            var self = this;
-            return _.filter(self.PosCategory, function(item){
-                return item.id === id;
-            });
-        },
 
         getAccountJournal: function (id) {
             var self = this;
@@ -414,21 +445,22 @@ function report_pos_orders(reporting){
             });
         },
 
+
         BuildTable: function(){
             var self = this;
             var data = [];
             var order;
-            var producto;
             var category;
-            var item;
+            var product;
             var store;
+            var item;
 
             for (var i = 0; i < this.PosOrderLine.length; i++) {
                 item = this.PosOrderLine[i];
-                producto = this.getProductProduct(item.product_id);
+                product = this.getProductProduct(item.product_id);
                 order = self.getPosOrder(item.order_id[0]).shift();
                 store = self.getAccountJournal(order.sale_journal[0]);
-                //category = self.getPosCategory(item.product_id[0]);
+
                 var place_id;
                 var place_name;
                 var floor;
@@ -439,7 +471,7 @@ function report_pos_orders(reporting){
                     place_name = order.table_id[1];
                 }
 
-                if (producto != undefined){
+                if (product != undefined){
 
                     if(store.length > 0){
 
@@ -461,41 +493,54 @@ function report_pos_orders(reporting){
                             product_name : item.product_id[1],
                             qty : accounting.formatNumber(item.qty,0,".",","),
                             price_unit : accounting.formatNumber(item.price_unit,0,".",","),
-                            standard_price : accounting.formatNumber((producto.standard_price),0, ".", ","),
+                            standard_price : accounting.formatNumber((product.standard_price),0, ".", ","),
                             price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
-                            standar_tot : accounting.formatNumber((item.qty * producto.standard_price),0, ".", ","),
-                            utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * producto.standard_price)),0, ".", ","),
+                            standar_tot : accounting.formatNumber((item.qty * product.standard_price),0, ".", ","),
+                            utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * product.standard_price)),0, ".", ","),
                             store_id : store[0].store_ids[0],
                             qty_total : item.qty,
                             price_tot_tot : ((item.qty * item.price_unit)),
-                            standar_tot_tot : ((item.qty * producto.standard_price)),
-                            utility_tot : (((item.qty * item.price_unit) - (item.qty * producto.standard_price))),
-                            category_name : producto.pos_categ_id[1],
-                            categ_id : (producto.pos_categ_id[0]),
-                            partner_id : order.partner_id[0],
+                            standar_tot_tot : ((item.qty * product.standard_price)),
+                            utility_tot : (((item.qty * item.price_unit) - (item.qty * product.standard_price))),
+                            category_name : product.categ_id.complete_name,
+                            category_id : product.categ_id.id,
+                            attribute_ids : product.attribute_ids,
+                            attribute_value_ids : product.atribute_value_ids,
+                            partner_id : order.partner_id[0]
                         });
                     }
                 }
             }
-            this.rowsData=data;
+
             self.content=data;
             this.loadTable(data);
         },
 
+        getProductProduct: function(pro_id){
+            var self = this;
+            return _.find(self.ProductProduct, function(item){
+                return _.contains(pro_id, item.id);
+            });
+        },
+
         fectSearch: function(){
             var self = this;
+
             var today = moment().format('YYYY-MM-DD');
             var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
             var month = moment().format('YYYY-MM');
             var last_month = moment().add(-1, 'months').format('YYYY-MM');
             var floor =this.$el.find('#current-floor').val();
             var table =this.$el.find('#current-table').val();
-            var categ = this.$el.find('#current-category').val();
             var store =this.$el.find('#current-store').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var product = this.$el.find('#product').val().split('-');
             var partner= this.$el.find('#partner').val().split('-');
+            var categ_ids = [];
+            var category = self.$el.find('#current-category').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
             var content = self.content;
 
             if ($('#A').is(":checked")){
@@ -536,6 +581,40 @@ function report_pos_orders(reporting){
                 $('#datepicker').css('display','none');
             }
 
+            if(category){
+                // Nivel 0, nivel 1
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id[0] == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                // Nivel 0, nivel 1, nivel 2
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                }) ;
+
+                categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+            };
+
+            if(category && category != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.category_id);
+                });
+            }
+
             // Filtrar por piso o delivery
             if (floor != 9999999){
                 content=_.filter(content, function (inv){
@@ -563,18 +642,24 @@ function report_pos_orders(reporting){
                 });
             }
 
-            if (categ != 9999999){
-                content =_.filter(content, function (inv){
-                    return inv.categ_id == categ[0];
-                });
-            }
-
             if (store != 9999999){
                 content=_.filter(content, function (inv){
                     return inv.store_id == store;
                 });
             }
 
+            if(attribute && attribute != 9999999 && attribute_value == 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_ids, parseInt(attribute));
+                });
+            }
+
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_value_ids, parseFloat(attribute_value));
+                });
+            }
+
             var qty_total_total = _.reduce(_.map(content,function(map){
                 return(map.qty_total);
             }),function(memo, num){
@@ -610,6 +695,33 @@ function report_pos_orders(reporting){
             self.loadTable(content)
         },
 
+        // updateSelections: function () {
+        //     var self = this;
+        //
+        //     var attribute = self.$el.find('#current-attribute').val();
+        //     if(attribute != 9999999){
+        //         /*=============================
+        //             ATTRIBUTE VALUE SELECTION
+        //         =============================*/
+        //         var attribute_value = self.$el.find('#current-attribute-value').empty();
+        //         self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+        //         _.each(self.ProductAttributeValue,function(item){
+        //             if(parseFloat(attribute) == item.attribute_id[0]){
+        //                 self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+        //             }
+        //         });
+        //     }else{
+        //         /*=============================
+        //             ATTRIBUTE VALUE SELECTION
+        //         =============================*/
+        //         var attribute_value = self.$el.find('#current-attribute-value').empty();
+        //         self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+        //         _.each(self.ProductAttributeValue,function(item){
+        //             self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+        //         });
+        //     }
+        // },
+
         searchProduct: function () {
             var self = this;
             var results = self.ProductProduct;
@@ -699,6 +811,8 @@ function report_pos_orders(reporting){
                         price_tot : {halign:'right' },
                         standar_tot : {halign:'right' },
                         utility : {halign:'right'},
+                        attribute_id : {halign:'left'},
+                        attribute_name : {halign:'left'},
                     },
                 margin: { top: 16, horizontal: 7},
                 addPageContent: function (data) {

+ 125 - 33
static/src/js/reports/report_purchases_invoice_analysis.js

@@ -24,6 +24,8 @@ function report_purchases_invoice_analysis (reporting){
             'click #Z' : 'factSearch',
             'click #Y' : 'factSearch',
             'change #current-category' : 'factSearch',
+            'change #current-attribute': 'factSearch',
+            'change #current-attribute-value': 'factSearch',
             'click #purchase' : 'factSearch',
             'click #expense' : 'factSearch',
             'change #current-store': 'factSearch',
@@ -132,14 +134,36 @@ function report_purchases_invoice_analysis (reporting){
                 return self.fetchAccountInvoiceLine();
             }).then(function (AccountInvoiceLine) {
                 self.AccountInvoiceLine = AccountInvoiceLine;
-                return self.fecthProductProduct();
+                return self.fetchProductProduct();
             }).then(function(ProductProduct){
                 self.ProductProduct = ProductProduct;
-                return self.fecthCategory();
-            }).then(function(productCategory){
-                self.productCategory = productCategory;
+                return self.fetchProductAttribute();
+            }).then(function (ProductAttribute) {
+                self.ProductAttribute = ProductAttribute;
+                if(ProductAttribute.length > 0){
+                    self.$el.find('#current-attribute').append('<option value="9999999">Todos los atributos</option>');
+                    _.each(ProductAttribute,function(item){
+                        self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute').css('display','none');
+                }
+                return self.fetchProductAttributeValue();
+            }).then(function(ProductAttributeValue){
+                self.ProductAttributeValue = ProductAttributeValue;
+                if(ProductAttributeValue.length > 0){
+                    self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                    _.each(ProductAttributeValue,function(item){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute-value').css('display','none');
+                }
+                return self.fetchProductCategory();
+            }).then(function(ProductCategory){
+                self.ProductCategory = ProductCategory;
                 self.$el.find('#current-category').append('<option value="9999999">Todos las categorias</option>');
-                _.each(productCategory, function (item) {
+                _.each(ProductCategory, function (item) {
                     self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
                 });
                 return self.fecthResCompany();
@@ -210,28 +234,53 @@ function report_purchases_invoice_analysis (reporting){
             });
             return defer;
         },
-        fecthProductProduct: function(){
+
+        fetchProductProduct: function(){
             var self = this;
-            var defer = $.Deferred();
-            var porductIDS = _.flatten(_.map(self.AccountInvoiceLine, function (item) {
+            var product_ids = _.flatten(_.map(self.AccountInvoiceLine, function (item) {
                 return item.product_id[0];
             }));
-            var ProductProduct =  new model.web.Model('product.product');
-            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type', 'categ_id','attribute_str'];
-            ProductProduct.query(fields).filter([['id', 'in', porductIDS],['active', '=', true]]).all().then(function (results) {
-                defer.resolve(results)
+            var domain = [['id','in',product_ids]];
+            var ProductProduct = new model.web.Model('product.product');
+            return ProductProduct.call('getProductProduct',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        // Buscar Category
+        fetchProductCategory: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','parent_id','complete_name'];
+            var ProductCategory = new model.web.Model('product.category');
+            ProductCategory.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
             });
             return defer;
         },
-        fecthCategory: function () {
+
+        fetchProductAttribute : function(){
             var self = this;
             var defer = $.Deferred();
-            var productCategory = new model.web.Model('product.category');
-            productCategory.query(['id', 'name', 'type']).filter([['type', '=', 'normal']]).all().then(function (results) {
+            var fields = ['id','name'];
+            var ProductAttribute = new model.web.Model('product.attribute');
+            ProductAttribute.query(fields).filter().all().then(function(results) {
                 defer.resolve(results);
             });
             return defer;
         },
+
+        fetchProductAttributeValue : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','attribute_id'];
+            var ProductAttributeValue = new model.web.Model('product.attribute.value');
+            ProductAttributeValue.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         fecthResCompany: function(){
             var self = this;
             var defer = $.Deferred();
@@ -299,7 +348,7 @@ function report_purchases_invoice_analysis (reporting){
             var item;
             var invoice;
             var store;
-            var producto = [];
+            var product = [];
             var invoice_type;
             for (var i = 0; i < this.AccountInvoiceLine.length; i++) {
                 item = this.AccountInvoiceLine[i];
@@ -309,17 +358,17 @@ function report_purchases_invoice_analysis (reporting){
                 }else{
                     invoice_type = 'purchase'
                 }
-                producto =this.getProductProduct(item.product_id);
+                product =this.getProductProduct(item.product_id);
 
-                if (producto != undefined){
+                if (product != undefined){
                     store = self.getAccountJournal(invoice.journal_id[0]);
                     if(store.length > 0){
                         data.push({
                             id : invoice.id,
                             number : (invoice.number),
-                            id_product : item.product_id[0],
-                            ean_product : self.valorNull(producto.ean13),
-                            name : (item.name),
+                            product_id : item.product_id[0],
+                            product_name : item.name,
+                            ean13 : self.valorNull(product.ean13),
                             quantity : accounting.formatNumber((item.quantity),0, ".", ","),
                             price_unity : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
                             standar_tot : accounting.formatNumber((item.quantity * item.price_unit),2, ".", ","),
@@ -330,8 +379,8 @@ function report_purchases_invoice_analysis (reporting){
                             date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
                             amount : (item.quantity * item.price_unit),
                             partner_name : invoice.partner_id[1],
-                            categ_id : (producto.categ_id[0]),
-                            categ_name : (producto.categ_id[1]),
+                            category_id : product.categ_id.id,
+                            category_name : product.categ_id.complete_name,
                             invoice_type : invoice_type,
                             store_id : store[0].store_ids[0]
                         });
@@ -349,7 +398,10 @@ function report_purchases_invoice_analysis (reporting){
             var last_month = moment().add(-1, 'months').format('YYYY-MM');
             var partner = this.$el.find('#partner').val().split('-');
             var product = this.$el.find('#product').val().split('-');
-            var categ = this.$el.find('#current-category').val().split('-');
+            var categ_ids = [];
+            var category = self.$el.find('#current-category').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
             var store =this.$el.find('#current-store').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
@@ -422,9 +474,49 @@ function report_purchases_invoice_analysis (reporting){
                 });
             }
 
-            if(categ != 9999999){
-                content = _.filter(content,function(inv){
-                    return inv.categ_id == categ[0];
+            if(category){
+                // Nivel 0, nivel 1
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id[0] == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                // Nivel 0, nivel 1, nivel 2
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                }) ;
+
+                categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+            };
+
+            if(category && category != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.category_id);
+                });
+            }
+
+            if(attribute && attribute != 9999999 && attribute_value == 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_ids, parseInt(attribute));
+                });
+            }
+
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_value_ids, parseFloat(attribute_value));
                 });
             }
 
@@ -545,14 +637,14 @@ function report_purchases_invoice_analysis (reporting){
             pdfDoc.autoTable(getColumns, rows, {
                 styles: { overflow: 'linebreak', fontSize: 7, columnWidth: 'wrap'},
                 columnStyles: {
-                    number: {fontStyle: 23},
+                    number: {columnWidth: 23},
                     date_create :{columnWidth: 18},
-                    partner_name :{columnWidth: '11px'},
-                    ean_product:{columnWidth: '8px'},
-                    name :{columnWidth: '10px'},
-                    categ_name : {columnWidth: '8px'},
-                    quantity :{halign:'right' },
+                    partner_name :{columnWidth: 35},
+                    ean13:{columnWidth: 14},
+                    product_name :{columnWidth: 70},
+                    category_name : {columnWidth: '8px'},
                     price_unity : {halign:'right' },
+                    quantity :{halign:'right' },
                     standar_tot : {halign:'right' },
                 },
                 margin: { top: 20, horizontal: 7},

+ 133 - 59
static/src/js/reports/report_sales_invoice_analysis.js

@@ -26,6 +26,8 @@ function report_sales_invoice_analysis (reporting){
             'change #current-store': 'fectSearch',
             'change #current-journal': 'fectSearch',
             'change #current-category' : 'fectSearch',
+            'change #current-attribute': 'fectSearch',
+            'change #current-attribute-value': 'fectSearch',
             'change #user': 'fectSearch',
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
@@ -142,15 +144,37 @@ function report_sales_invoice_analysis (reporting){
                 return self.fetchInvoiceLine(invoices);
             }).then(function (invoiceLines) {
                 self.invoiceLines = invoiceLines;
-                return self.fecthProduct(invoiceLines);
+                return self.fetchProductProduct();
             }).then(function(ProductProduct){
                 self.ProductProduct = ProductProduct;
-                return self.fecthCategory();
-            }).then(function(productCategory){
-                self.productCategory = productCategory;
+                return self.fetchProductAttribute();
+            }).then(function (ProductAttribute) {
+                self.ProductAttribute = ProductAttribute;
+                if(ProductAttribute.length > 0){
+                    self.$el.find('#current-attribute').append('<option value="9999999">Todos los atributos</option>');
+                    _.each(ProductAttribute,function(item){
+                        self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute').css('display','none');
+                }
+                return self.fetchProductAttributeValue();
+            }).then(function(ProductAttributeValue){
+                self.ProductAttributeValue = ProductAttributeValue;
+                if(ProductAttributeValue.length > 0){
+                    self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                    _.each(ProductAttributeValue,function(item){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute-value').css('display','none');
+                }
+                return self.fetchProductCategory();
+            }).then(function(ProductCategory){
+                self.ProductCategory= ProductCategory;
                 self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
-                _.each(productCategory, function (item) {
-                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
+                _.each(ProductCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.complete_name + '</option>');
                 });
                 return self.fecthCompanyCurrency();
             }).then(function(resCompany){
@@ -278,18 +302,6 @@ function report_sales_invoice_analysis (reporting){
             return defer;
         },
 
-        fecthCompanyCurrency: function(){
-            var self = this;
-            var defer = $.Deferred();
-            var field=['id','name', 'currency_id'];
-            var domain = [['id', '=', self.session.company_id]];
-            var ResCompany = new model.web.Model('res.company');
-            ResCompany.query(field).filter(domain).all().then(function(results){
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
         // Invoice (FACTURAS)
         fetchInvoiceV2: function () {
             var self = this;
@@ -386,30 +398,53 @@ function report_sales_invoice_analysis (reporting){
         },
 
         // Product Product
-        fecthProduct: function(invoiceLines){
-            var defer = $.Deferred();
-            var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
+        fetchProductProduct: function(){
+            var self = this;
+            var product_ids = _.flatten(_.map(self.invoiceLines, function (item) {
                 return item.product_id[0];
             }));
-            var ProductProduct =  new model.web.Model('product.product');
-            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type', 'categ_id','attribute_str'];
-            ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
-                defer.resolve(results)
+            var domain = [['id','in',product_ids]];
+            var ProductProduct = new model.web.Model('product.product');
+            return ProductProduct.call('getProductProduct',[domain], {
+                context: new model.web.CompoundContext()
             });
-            return defer;
         },
 
         // Buscar Category
-        fecthCategory: function () {
+        fetchProductCategory : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','parent_id','complete_name'];
+            var ProductCategory = new model.web.Model('product.category');
+            ProductCategory.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchProductAttribute : function(){
             var self = this;
             var defer = $.Deferred();
-            var productCategory = new model.web.Model('product.category');
-            productCategory.query(['id', 'name', 'type']).filter([['type', '=', 'normal']]).all().then(function (results) {
+            var fields = ['id','name'];
+            var ProductAttribute = new model.web.Model('product.attribute');
+            ProductAttribute.query(fields).filter().all().then(function(results) {
                 defer.resolve(results);
             });
             return defer;
         },
 
+        fetchProductAttributeValue : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','attribute_id'];
+            var ProductAttributeValue = new model.web.Model('product.attribute.value');
+            ProductAttributeValue.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+
         // Obtener Monedas de la Factura
         getResCurrency: function (id) {
             var self = this;
@@ -434,10 +469,10 @@ function report_sales_invoice_analysis (reporting){
         },
 
         // Obtener las lineas de las Facturas
-        getProduct: function(pro_id){
+        getProductProduct: function(pro_id){
             var self = this;
-            return _.find(self.ProductProduct, function(prod){
-                return _.contains(pro_id, prod.id);
+            return _.find(self.ProductProduct, function(item){
+                return _.contains(pro_id, item.id);
             });
         },
 
@@ -455,8 +490,7 @@ function report_sales_invoice_analysis (reporting){
             var item;
             var invoice=[];
             var voucher;
-            var producto;
-            var attribute;
+            var product;
 
             for (var i = 0; i < this.invoiceLines.length; i++) {
                 item = this.invoiceLines[i];
@@ -474,40 +508,37 @@ function report_sales_invoice_analysis (reporting){
                     pago_name= '';
                 }
 
-                producto =this.getProduct(item.product_id);
+                product =this.getProductProduct(item.product_id);
 
-                if (producto != undefined){
-                    if(producto.attribute_str){
-                        attribute = ' ' + self.valorNull(producto.attribute_str);
-                    }else{
-                        attribute = ' ';
-                    }
+                if (product != undefined){
                     var store_id = self.getAccountJournal(invoice.journal_id[0]);
                     if(store_id.length > 0){
                         data.push({
                             id : invoice.id,
                             number : (invoice.number),
-                            id_product : producto.id,
-                            ean_product : self.valorNull(producto.ean13),
-                            name : (item.name + attribute),
+                            product_id : item.product_id[0],
+                            product_name : item.product_id[1],
+                            ean13 : self.valorNull(product.ean13),
                             quantity : accounting.formatNumber((item.quantity),0, ".", ","),
                             price_unity : accounting.formatNumber((item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent)),0, ".", ","),
-                            standar_price : accounting.formatNumber((producto.standard_price),0, ".", ","),
+                            standar_price : accounting.formatNumber((product.standard_price),0, ".", ","),
                             price_tot : accounting.formatNumber((item.quantity * (item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent))),0, ".", ","),
-                            standar_tot : accounting.formatNumber((item.quantity * producto.standard_price),0, ".", ","),
-                            utility : accounting.formatNumber(((item.quantity * (item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent))) - (item.quantity * producto.standard_price)),0, ".", ","),
+                            standar_tot : accounting.formatNumber((item.quantity * product.standard_price),0, ".", ","),
+                            utility : accounting.formatNumber(((item.quantity * (item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent))) - (item.quantity * product.standard_price)),0, ".", ","),
                             journal_id : pago,
                             journal_name : pago_name,
                             quantity_tot : (item.quantity),
                             price_tot_tot : ((item.quantity * (item.price_unit *(CurrencyBase.rate_silent/currency.rate_silent)))),
-                            standar_tot_tot : ((item.quantity * producto.standard_price)),
-                            utility_tot : (((item.quantity * (item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent))) - (item.quantity * producto.standard_price))),
+                            standar_tot_tot : ((item.quantity * product.standard_price)),
+                            utility_tot : (((item.quantity * (item.price_unit * (CurrencyBase.rate_silent/currency.rate_silent))) - (item.quantity * product.standard_price))),
                             date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
                             date_invoice : (invoice.date_invoice),
                             partner_id : invoice.partner_id[0],
                             partner_name : invoice.partner_id[1],
-                            categ_id : (producto.categ_id[0]),
-                            categ_name : (producto.categ_id[1]),
+                            category_name : product.categ_id.complete_name,
+                            category_id : product.categ_id.id,
+                            attribute_ids : product.attribute_ids,
+                            attribute_value_ids : product.atribute_value_ids,
                             user_id : self.valorNull(invoice.user_id[0]),
                             user_name : invoice.user_id[1],
                             store_id : store_id[0].store_ids[0],
@@ -529,7 +560,10 @@ function report_sales_invoice_analysis (reporting){
             var partner = this.$el.find('#partner').val().split('-');
             var user = this.$el.find('#user').val().split('-');
             var product = this.$el.find('#product').val().split('-');
-            var categ = this.$el.find('#current-category').val().split('-');
+            var categ_ids = [];
+            var category = self.$el.find('#current-category').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var store = this.$el.find('#current-store').val();
@@ -581,7 +615,41 @@ function report_sales_invoice_analysis (reporting){
             }
             if (product != ""){
                 content = _.filter(content, function(inv){
-                    return inv.id_product == product[0];
+                    return inv.product_id == product[0];
+                });
+            }
+
+            if(category){
+                // Nivel 0, nivel 1
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id[0] == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                // Nivel 0, nivel 1, nivel 2
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                }) ;
+
+                categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+            };
+
+            if(category && category != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.category_id);
                 });
             }
 
@@ -603,9 +671,15 @@ function report_sales_invoice_analysis (reporting){
                 });
             }
 
-            if (categ != 9999999){
-                content =_.filter(content, function (inv){
-                    return inv.categ_id == categ[0];
+            if(attribute && attribute != 9999999 && attribute_value == 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_ids, parseInt(attribute));
+                });
+            }
+
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_value_ids, parseFloat(attribute_value));
                 });
             }
 
@@ -735,9 +809,9 @@ function report_sales_invoice_analysis (reporting){
                               date_create :{columnWidth: 18},
                               partner_name:{columnWidth: 16},
                               journal_name:{columnWidth: 25},
-                              ean_product:{columnWidth: 12},
-                              name :{columnWidth: 45},
-                              categ_name : {columnWidth: 40},
+                              ean13:{columnWidth: 12},
+                              product_name :{columnWidth: 45},
+                              category_name : {columnWidth: 40},
                               quantity :{halign:'right',columnWidth: 9},
                               price_unity : {halign:'right',columnWidth: '20%'},
                               standar_price : {halign:'right',columnWidth: '18%'},

+ 309 - 186
static/src/js/reports/report_ventas_pos_orders.js

@@ -25,6 +25,9 @@ function report_ventas_pos_orders(reporting){
             'click #D' : 'fectSearch',
             'click #Z' : 'fectSearch',
             'change #current-store': 'fectSearch',
+            'change #current-category' : 'fectSearch',
+            'change #current-attribute': 'fectSearch',
+            'change #current-attribute-value': 'fectSearch',
             'change #from' : 'fectSearch',
             'change #to': 'fectSearch',
             'click-row.bs.table #table' : 'clickAnalysisDetail',
@@ -97,10 +100,10 @@ function report_ventas_pos_orders(reporting){
                     res_model: "account.invoice",
                     views: [[false,'form']],
                     target: 'new',
-                    domain: [['type', '=', 'out_invoice'],['id','=', row.order_id]],
+                    domain: [['type', '=', 'out_invoice'],['id','=', row.id]],
                     context: {},
                     flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
-                    res_id: row.order_id,
+                    res_id: row.id,
                 });
             }
             if (field == 'order_name'){
@@ -191,6 +194,35 @@ function report_ventas_pos_orders(reporting){
                 return self.fetchProductProduct();
             }).then(function (ProductProduct) {
                 self.ProductProduct = ProductProduct;
+                return self.fetchProductAttribute();
+            }).then(function (ProductAttribute) {
+                self.ProductAttribute = ProductAttribute;
+                if(ProductAttribute.length > 0){
+                    self.$el.find('#current-attribute').append('<option value="9999999">Todos los atributos</option>');
+                    _.each(ProductAttribute,function(item){
+                        self.$el.find('#current-attribute').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute').css('display','none');
+                }
+                return self.fetchProductAttributeValue();
+            }).then(function(ProductAttributeValue){
+                self.ProductAttributeValue = ProductAttributeValue;
+                if(ProductAttributeValue.length > 0){
+                    self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                    _.each(ProductAttributeValue,function(item){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.attribute-value').css('display','none');
+                }
+                return self.fetchProductCategory();
+            }).then(function(ProductCategory){
+                self.ProductCategory= ProductCategory;
+                self.$el.find('#current-category').append('<option value="9999999">Todas las categorias</option>');
+                _.each(ProductCategory, function (item) {
+                    self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.complete_name + '</option>');
+                });
                 return self.fecthResStore();
             }).then(function(ResStore){
                 self.ResStore = ResStore;
@@ -201,18 +233,24 @@ function report_ventas_pos_orders(reporting){
                 return self.fecthAccountJournal();
             }).then(function(AccountJournal){
                 self.AccountJournal = AccountJournal;
-                return self.fetchInvoiceV2();
-            }).then(function (invoices){
-                self.invoices = invoices;
-                return self.fetchInvoiceLine(invoices);
-            }).then(function (invoiceLines) {
-                self.invoiceLines = invoiceLines;
-                return self.fecthProduct(invoiceLines);
-            }).then(function(ProductInvoice){
-                self.ProductInvoice = ProductInvoice;
+                return self.fetchAccountInvoice();
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceLine();
+            }).then(function (AccountInvoiceLine) {
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.fetchResCurrency();
+            }).then(function(ResCurrency){
+                self.ResCurrency = ResCurrency;
                 return self.fetchResPartner();
             }).then(function (ResPartner){
                 self.ResPartner = ResPartner;
+                return self.fetchProductPricelist();
+            }).then(function(ProductPricelist){
+                self.ProductPricelist = ProductPricelist;
+                return self.fecthCompanyCurrency();
+            }).then(function(resCompany){
+                self.resCompany = resCompany;
                 self.search();
                 self.searchProduct();
                 return self.BuildTable();
@@ -233,11 +271,23 @@ function report_ventas_pos_orders(reporting){
             return defer;
         },
 
+        // Obtener Pedido
+        fecthResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id', 'name'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         fecthAccountJournal: function(){
             var self = this;
             var defer = $.Deferred();
             var field = ['id', 'name','store_ids'];
-            var domain = [['active','=',true],['type','in',['sale','purchase']]];
+            var domain = [['active','=',true],['type','in',['sale']]];
             var AccountJournal = new model.web.Model('account.journal');
             AccountJournal.query(field).filter(domain).all().then(function(results){
                 defer.resolve(results);
@@ -245,8 +295,32 @@ function report_ventas_pos_orders(reporting){
             return defer;
         },
 
+        fecthCompanyCurrency: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field=['id','name', 'currency_id'];
+            var domain = [['id', '=', self.session.company_id]];
+            var ResCompany = new model.web.Model('res.company');
+            ResCompany.query(field).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchProductPricelist : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','currency_id'];
+            var domain = [['active', '=', true],['type', '=', 'sale']];
+            var ProductPricelist = new model.web.Model('product.pricelist');
+            ProductPricelist.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
         // Invoice (FACTURAS)
-        fetchInvoiceV2: function () {
+        fetchAccountInvoice: function () {
             var self = this;
             var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
             var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
@@ -258,22 +332,22 @@ function report_ventas_pos_orders(reporting){
             filter=filter.concat("]");
             var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
             var defer = $.Deferred();
-            var Invoice = new model.web.Model('account.invoice');
-            Invoice.query(field).filter(filter).all().then(function (results) {
+            var AccountInvoice = new model.web.Model('account.invoice');
+            AccountInvoice.query(field).filter(filter).all().then(function (results) {
                 defer.resolve(results);
             });
             return defer;
         },
 
         // Invoice line (Linea de Factura)
-        fetchInvoiceLine: function (invoices) {
+        fetchAccountInvoiceLine: function () {
             var self = this;
             var defer = $.Deferred();
-            var linesIds = _.flatten(_.map(self.invoices, function (item) {
+            var linesIds = _.flatten(_.map(self.AccountInvoice, function (item) {
                 return item.invoice_line;
             }));
-            var InvoiceLine = new model.web.Model('account.invoice.line');
-            InvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
+            var AccountInvoiceLine = new model.web.Model('account.invoice.line');
+            AccountInvoiceLine.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
                 defer.resolve(results)
             });
             return defer;
@@ -292,17 +366,26 @@ function report_ventas_pos_orders(reporting){
             return defer;
         },
 
-        // Product Product
-        fecthProduct: function(invoiceLines){
+        fetchResCurrency : function(){
             var self = this;
             var defer = $.Deferred();
-            var porductIDS = _.flatten(_.map(self.invoiceLines, function (item) {
-                return item.product_id[0];
-            }));
-            var ProductInvoice =  new model.web.Model('product.product');
-            var fields = ['id','name', 'default_code', 'name_template','ean13', 'standard_price','type','attribute_str'];
-            ProductInvoice.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
-                defer.resolve(results)
+            var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+            var domain = [['active', '=', true]];
+            var ResCurrency = new model.web.Model('res.currency');
+            ResCurrency.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        // Buscar Category
+        fetchProductCategory : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','parent_id','complete_name'];
+            var ProductCategory = new model.web.Model('product.category');
+            ProductCategory.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
             });
             return defer;
         },
@@ -311,14 +394,8 @@ function report_ventas_pos_orders(reporting){
         fetchPosOrder: function () {
             var self = this;
             var defer = $.Deferred();
-            // var modules = self.checkModel('point_of_sale');
-            //
-            // if (modules.length <= 0){
-            //     self.showMensaje('point_of_sale');
-            //     return defer;
-            // }
-
-            var fields = ['id','name','partner_id','create_date','lines','table_id','sale_journal'];
+
+            var fields = ['id','number', 'name','partner_id','create_date','lines','table_id','sale_journal','pricelist_id'];
             var domain = [['state', 'not in', ['draft','cancel']]];
             var PosOrder = new model.web.Model('pos.order');
             PosOrder.query(fields).filter(domain).all().then(function(results){
@@ -343,46 +420,65 @@ function report_ventas_pos_orders(reporting){
             return defer;
         },
 
-        // Productos
+        // Product Product
         fetchProductProduct: function(){
             var self = this;
-            var defer = $.Deferred();
-            var porduct_ids = _.flatten(_.map(self.PosOrderLine, function (item) {
+            var product_ids = _.flatten(_.map(self.AccountInvoiceLine, function (item) {
                 return item.product_id[0];
             }));
-            var fields = ['id','name', 'default_code', 'name_template','ean13','lst_price','pos_categ_id', 'standard_price','type','attribute_str'];
-            var domain = [['id', 'in', porduct_ids]];
-            var ProductProduct =  new model.web.Model('product.product');
-            ProductProduct.query(fields).filter(domain).all().then(function (results) {
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var product_order_ids =  _.flatten(_.map(self.PosOrderLine, function (item) {
+                    return item.product_id[0];
+                }));
+                product_ids = product_ids.concat(product_order_ids);
+            }
+
+            var domain = [['id','in',product_ids]];
+            var ProductProduct = new model.web.Model('product.product');
+            return ProductProduct.call('getProductProduct',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        fetchProductAttribute : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name'];
+            var ProductAttribute = new model.web.Model('product.attribute');
+            ProductAttribute.query(fields).filter().all().then(function(results) {
                 defer.resolve(results);
             });
             return defer;
         },
 
-        getPosOrder: function(id){
+        fetchProductAttributeValue : function(){
             var self = this;
-            return _.filter(self.PosOrder,function (item) {
-                return item.id == id;
+            var defer = $.Deferred();
+            var fields = ['id','name','attribute_id'];
+            var ProductAttributeValue = new model.web.Model('product.attribute.value');
+            ProductAttributeValue.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
             });
+            return defer;
         },
 
-        // Obtener las lineas de las Facturas
-        getProductProduct: function(id){
+        getPosOrder: function (id) {
             var self = this;
-
-            return _.filter(self.ProductProduct, function(item){
+            return _.filter(self.PosOrder,function (item) {
                 return item.id === id;
-            });
+            })
         },
 
         // Obtener las lineas de las Facturas
-        getProductInvoice: function(id){
+        getProductProduct: function(pro_id){
             var self = this;
-            return _.filter(self.ProductInvoice, function(item){
-                return item.id === id;
+            return _.find(self.ProductProduct, function(item){
+                return _.contains(pro_id, item.id);
             });
         },
 
+
         getAccountJournal: function (id) {
             var self = this;
             return _.filter(self.AccountJournal,function (item) {
@@ -416,126 +512,136 @@ function report_ventas_pos_orders(reporting){
             });
         },
 
-
-        // Obtener Pedido
-        fecthResStore: function(){
+        getAccountInvoice: function (id) {
             var self = this;
-            var defer = $.Deferred();
-            var field=['id', 'name'];
-            var ResStore = new model.web.Model('res.store');
-            ResStore.query(field).all().then(function(results){
-                defer.resolve(results);
-            });
-            return defer;
+            return _.filter(self.AccountInvoice,function (item) {
+                return item.id === id;
+            })
         },
 
-        // Obtener la Detalles de la Factura
-        getInvoice: function (id_line){
-            return _.find(this.invoices, function (inv) {
-                return _.contains(inv.invoice_line, id_line);
-            });
+        getProductPricelist: function (id) {
+            var self = this;
+            return _.filter(self.ProductPricelist,function (item) {
+                return item.id === id;
+            })
         },
 
-        getAccountJournalVentas: function (id) {
+        getResCurrency: function (id) {
             var self = this;
-            return _.filter(self.AccountJournal,function (item) {
+            return _.filter(self.ResCurrency,function (item) {
                 return item.id === id;
-            });
+            })
         },
 
         BuildTable: function(){
             var self = this;
+           var CurrencyBase = self.getResCurrency(self.resCompany[0].currency_id[0]).shift();
             var data = [];
-            var order;
             var sale;
             var itemsale;
-            var producto = [];
             var saleproducto = [];
             var item;
 
-            for (var i = 0; i < this.PosOrderLine.length; i++) {
-
-
-                item = this.PosOrderLine[i];
-                producto = self.getProductProduct(item.product_id[0]);
-                order = self.getPosOrder(item.order_id[0]).shift();
-                var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
-                var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
-                var date_aux=moment(utc._d).format('YYYY-MM-DD');
-               var store = self.getAccountJournal(order.sale_journal[0]);
-
-                if(store.length > 0 && producto.length > 0){
-
-                    data.push({
-                        id : item.id,
-                        order_id : item.order_id[0],
-                        ref: "",
-                        order_name : item.order_id[1],
-                        date : date_aux,
-                        date_order : date,
-                        partner: order.partner_id[1],
-                        product_id : item.product_id[0],
-                        product_name : item.product_id[1],
-                        qty : accounting.formatNumber(item.qty,0,".",","),
-                        price_unit : accounting.formatNumber(item.price_unit,0,".",","),
-                        standard_price : accounting.formatNumber((producto[0].standard_price),0, ".", ","),
-                        price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
-                        standar_tot : accounting.formatNumber((item.qty * producto[0].standard_price),0, ".", ","),
-                        utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * producto[0].standard_price)),0, ".", ","),
-                        qty_total : item.qty,
-                        price_tot_tot : ((item.qty * item.price_unit)),
-                        standar_tot_tot : ((item.qty * producto[0].standard_price)),
-                        partner_id : order.partner_id[0],
-                        utility_tot : (((item.qty * item.price_unit) - (item.qty * producto[0].standard_price))),
-                        store_id : store[0].store_ids[0],
-                    });
+                for (var k = 0; k < this.PosOrderLine.length; k++) {
+                    item = this.PosOrderLine[k];
+                    var order = self.getPosOrder(item.order_id[0]).shift();
+                    var utc = moment.utc(item.create_date,'YYYY-MM-DD h:mm:ss A');
+                    var date = moment(utc._d).format('DD/MM/YYYY h:mm A');
+                    var date_aux=moment(utc._d).format('YYYY-MM-DD');
+                    var pricelist = self.getProductPricelist(order.pricelist_id[0]).shift();
+                    var currency = self.getResCurrency(pricelist.currency_id[0]).shift();
+                    var product = this.getProductProduct(item.product_id);
+
+                    if (product != undefined){
+                        var store = self.getAccountJournal(order.sale_journal[0]);
+                        if(store.length > 0){
+                            data.push({
+                                id : item.id,
+                                order_id : item.order_id[0],
+                                order_name: item.order_id[1],
+                                ref : "",
+                                partner_id : order.partner_id[0],
+                                product_id : item.product_id[0],
+                                number : order.name,
+                                date : date_aux,
+                                date_order : date,
+                                partner : order.partner_id[1],
+                                product_name : item.product_id[1],
+                                price_unit_total : accounting.formatMoney(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                price_subtotal_total : accounting.formatMoney(item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                amount_total : accounting.formatMoney((item.price_unit * item.qty) * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                price_unit : accounting.formatNumber(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent),0,".",","),
+                                qty : accounting.formatNumber(item.qty,0,".",","),
+                                standard_price : accounting.formatNumber((product.standard_price),0, ".", ","),
+                                price_tot : accounting.formatNumber((item.qty * item.price_unit),0, ".", ","),
+                                standar_tot : accounting.formatNumber((item.qty * product.standard_price),0, ".", ","),
+                                utility : accounting.formatNumber(((item.qty * item.price_unit) - (item.qty * product.standard_price)),0, ".", ","),
+                                qty_total : item.qty,
+                                price_tot_tot : ((item.qty * item.price_unit)),
+                                standar_tot_tot : ((item.qty * product.standard_price)),
+                                price_subtotal : item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent),
+                                category_name : product.categ_id.complete_name,
+                                category_id : product.categ_id.id,
+                                utility : accounting.formatNumber((((item.qty * item.price_unit)* (CurrencyBase.rate_silent / currency.rate_silent)) - (item.qty * product.standard_price)),0, ".", ","),
+                                attribute_ids : product.attribute_ids,
+                                attribute_value_ids : product.atribute_value_ids,
+                                utility_tot : ((((item.qty * item.price_unit) * (CurrencyBase.rate_silent / currency.rate_silent)) - (item.qty * product.standard_price))),
+                                store_id : store[0].store_ids[0],
+                            });
+                        }
+                    }
                 }
-            }
-
-            for (var k = 0; k < this.invoiceLines.length; k++) {
-                itemsale = this.invoiceLines[k];
-
-                sale = this.getInvoice(itemsale.id);
-
-                saleproducto = this.getProductInvoice(itemsale.product_id[0]);
 
 
-                 if (!saleproducto){
-                     saleproducto={};
-                     saleproducto.standard_price=0;
-                 }
-
-                var storeVenta = self.getAccountJournalVentas(sale.journal_id[0]);
-                if (!storeVenta){
-                    storeVenta={};
-                    storeVenta.standard_price=0;
-                }
-                if(storeVenta.length > 0 && saleproducto.length > 0){
-                    data.push({
-                        id : itemsale.id,
-                        order_id : itemsale.invoice_id[0],
-                        ref: itemsale.invoice_id[1],
-                        order_name : "",
-                        date : sale.create_date,
-                        date_order : moment(sale.create_date).format("DD/MM/YYYY"),
-                        partner: sale.partner_id[1],
-                        product_id : itemsale.product_id[0],
-                        product_name : itemsale.product_id[1],
-                        qty : accounting.formatNumber(itemsale.quantity,0,".",","),
-                        price_unit : accounting.formatNumber(itemsale.price_unit,0,".",","),
-                        standard_price : accounting.formatNumber((saleproducto[0].standard_price),0, ".", ","),
-                        price_tot : accounting.formatNumber((itemsale.quantity * itemsale.price_unit),0, ".", ","),
-                        standar_tot : accounting.formatNumber((itemsale.quantity * saleproducto[0].standard_price),0, ".", ","),
-                        utility : accounting.formatNumber(((itemsale.quantity * itemsale.price_unit) - (itemsale.quantity * saleproducto[0].standard_price)),0, ".", ","),
-                        qty_total : itemsale.quantity,
-                        price_tot_tot : ((itemsale.quantity * itemsale.price_unit)),
-                        standar_tot_tot : ((itemsale.quantity * saleproducto[0].standard_price)),
-                        partner_id : sale.partner_id[0],
-                        utility_tot : (((itemsale.quantity * itemsale.price_unit) - (itemsale.quantity * saleproducto[0].standard_price))),
-                        store_id : storeVenta[0].store_ids[0],
-                    });
+                for (var i = 0; i < this.AccountInvoiceLine.length; i++) {
+                   item = this.AccountInvoiceLine[i];
+                    var invoice = self.getAccountInvoice(item.invoice_id[0]).shift();
+                    var currency = self.getResCurrency(invoice.currency_id[0]).shift();
+                    var product = this.getProductProduct(item.product_id);
+                    if (!product){
+                            product={};
+                            product.standard_price=0;
+                            product.categ_id="";
+                    }
+                    if (product != undefined){
+                        var storeVenta = self.getAccountJournal(invoice.journal_id[0]);
+                        if(storeVenta.length > 0){
+                            data.push({
+                                id : item.id,
+                                order_id : "",
+                                ref : item.invoice_id[1],
+                                partner_id : invoice.partner_id[0],
+                                product_id : item.product_id[0],
+                                number : invoice.number,
+                                date : date_aux,
+                                date_order : date,
+                                partner : invoice.partner_id[1],
+                                product_name : item.product_id[1],
+                                price_unit_total : accounting.formatMoney(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                price_subtotal_total : accounting.formatMoney(item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                amount_total : accounting.formatMoney((item.price_unit * item.quantity) * (CurrencyBase.rate_silent / currency.rate_silent), '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                                price_unit : accounting.formatNumber(item.price_unit * (CurrencyBase.rate_silent / currency.rate_silent),0,".",","),
+                                qty : accounting.formatNumber(item.quantity,0,".",","),
+                                standard_price : accounting.formatNumber((product.standard_price),0, ".", ","),
+                                price_tot : accounting.formatNumber((item.quantity * item.price_unit),0, ".", ","),
+                                standar_tot : accounting.formatNumber((item.quantity * product.standard_price),0, ".", ","),
+                                utility : accounting.formatNumber(((item.quantity * item.price_unit) - (item.quantity * product.standard_price)),0, ".", ","),
+                                qty_total : item.quantity,
+                                price_tot_tot : ((item.quantity * item.price_unit)),
+                                standar_tot_tot : ((item.quantity * product.standard_price)),
+                                price_subtotal : item.price_subtotal * (CurrencyBase.rate_silent / currency.rate_silent),
+                                category_name : product.categ_id.complete_name,
+                                category_id : product.categ_id.id,
+                                utility : accounting.formatNumber((((item.quantity * item.price_unit)* (CurrencyBase.rate_silent / currency.rate_silent)) - (item.quantity * product.standard_price)),0, ".", ","),
+                                attribute_ids : product.attribute_ids,
+                                attribute_value_ids : product.atribute_value_ids,
+                                utility_tot : ((((item.quantity * item.price_unit) * (CurrencyBase.rate_silent / currency.rate_silent)) - (item.quantity * product.standard_price))),
+                                store_id : storeVenta[0].store_ids[0],
+                            });
+                        }
+                    }
                 }
-            }
+
             this.rowsData=data;
             self.content=data;
             this.loadTable(data)
@@ -550,6 +656,10 @@ function report_ventas_pos_orders(reporting){
             var desde =this.$el.find('#from').val();
             var hasta =this.$el.find('#to').val();
             var store = this.$el.find('#current-store').val();
+            var categ_ids = [];
+            var category = self.$el.find('#current-category').val();
+            var attribute = self.$el.find('#current-attribute').val();
+            var attribute_value = self.$el.find('#current-attribute-value').val();
             var partner= this.$el.find('#partner').val().split('-');
             var product = this.$el.find('#product').val().split('-');
             var content = self.content;
@@ -600,6 +710,52 @@ function report_ventas_pos_orders(reporting){
                 });
             }
 
+            if(category){
+                // Nivel 0, nivel 1
+                var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return item.id == category || item.parent_id[0] == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                // Nivel 0, nivel 1, nivel 2
+                var category_children_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+
+                var category_grandchildren_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_children_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                }) ;
+
+                categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                    return _.contains(category_grandchildren_ids, item.parent_id[0]) || item.id == category;
+                }), function(map){
+                    return map.id;
+                });
+            };
+
+            if(category && category != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(categ_ids, inv.category_id);
+                });
+            }
+
+            if(attribute && attribute != 9999999 && attribute_value == 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_ids, parseInt(attribute));
+                });
+            }
+
+            if(attribute_value && attribute_value != 9999999){
+                content = _.filter(content,function (inv) {
+                    return _.contains(inv.attribute_value_ids, parseFloat(attribute_value));
+                });
+            }
+
             if (partner != ""){
                 content = _.filter(content, function(inv){
                     return inv.partner_id == partner[0];
@@ -685,39 +841,6 @@ function report_ventas_pos_orders(reporting){
             var rows=[];
             var rows = self.rowsData;
 
-            // var qty =_.reduce(_.map(rows,function(map){
-            //     return(map.qty_total);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            //
-            // var price_tot =_.reduce(_.map(rows,function(map){
-            //     return(map.price_tot_tot);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            //
-            // var standar_tot =_.reduce(_.map(rows,function(map){
-            //     return(map.standar_tot_tot);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            //
-            // var utility =_.reduce(_.map(rows,function(map){
-            //     return(map.utility_tot);
-            // }),function(memo, num){
-            //     return memo + num;
-            // },0);
-            //
-            // if (rows.length > 0){
-            //     rows.push({
-            //             order_name : "Totales ",
-            //             qty : accounting.formatNumber(qty,0,".",","),
-            //             price_tot : accounting.formatNumber(price_tot,0,".",","),
-            //             standar_tot : accounting.formatNumber(standar_tot,0,".",","),
-            //             utility : accounting.formatNumber(utility,0,".",","),
-            //     });
-            // }
             return rows;
         },
 

+ 11 - 2
static/src/reports/report_pos_orders.xml

@@ -55,8 +55,9 @@
                             <div class="panel-heading">Características</div>
                             <div class="panel-body">
                                 <div class="form-group">
-                                    <label for="current-category">Todas las categorias: </label>
-                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="category"></select>
+                                    <label>Categoria</label>
+                                    <select id="current-category" class="form-control form-control-sm">
+                                    </select>
                                     <label for="current-floor">Ubicacion: </label>
                                     <select id="current-floor" class="form-control ui-autocomplete-input"  name="floor"></select>
                                     <label for="current-table">Lugar: </label>
@@ -69,6 +70,14 @@
                                     <label for="partner">Buscar Cliente:</label>
                                     <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
 
+                                    <label>Atributo</label>
+                                    <select id="current-attribute" class="form-control form-control-sm">
+                                    </select>
+
+                                    <label>Valor del Atributo</label>
+                                    <select id="current-attribute-value" class="form-control form-control-sm">
+                                    </select>
+
                                     <label for="current-store">Sucursal: </label>
                                     <select id="current-store" class="form-control ui-autocomplete-input" name="store"></select>
                                 </div>

+ 17 - 5
static/src/reports/report_purchases_invoice_analysis.xml

@@ -64,8 +64,19 @@
                                     <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
                                 </div>
                                 <div class="form-group">
-                                    <label for="current-category">Todas las categorias: </label>
-                                    <select id="current-category" class="form-control ui-autocomplete-input"  name="category"></select>
+                                    <label>Categoria</label>
+                                    <select id="current-category" class="form-control form-control-sm">
+                                    </select>
+                                </div>
+                                <div class="form-group">
+                                    <label>Atributo</label>
+                                    <select id="current-attribute" class="form-control form-control-sm">
+                                    </select>
+                                </div>
+                                <div class="form-group">
+                                    <label>Valor del Atributo</label>
+                                    <select id="current-attribute-value" class="form-control form-control-sm">
+                                    </select>
                                 </div>
                                 <div class="form-group">
                                     <label for="current-store">Sucursal: </label>
@@ -109,10 +120,11 @@
                         <th data-field="number" data-sortable="true">Factura</th>
                         <th data-field="date_create" data-sortable="true">Fecha</th>
                         <th data-field="partner_name" data-sortable="true">Proveedor</th>
-                        <th data-field="categ_name" data-sortable="true">Categoria</th>
-                        <th data-field="name" data-sortable="true">Producto</th>
-                        <th data-field="quantity" data-sortable="true" data-align="right">Cantidad</th>
+                        <th data-field="ean13" data-sortable="true">Cod. Barra</th>
+                        <th data-field="product_name" data-sortable="true">Producto</th>
+                        <th data-field="category_name" data-sortable="true">Categoria</th>
                         <th data-field="price_unity" data-sortable="true" data-align="right">Precio Unitario</th>
+                                                <th data-field="quantity" data-sortable="true" data-align="right">Cantidad</th>
                         <th data-field="standar_tot" data-sortable="true" data-align="right">Total Costo</th>
                     </tr>
                 </thead>

+ 16 - 5
static/src/reports/report_sales_invoice_analysis.xml

@@ -60,8 +60,9 @@
                                     <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off"/>
                                 </div>
                                 <div class="form-group">
-                                    <label for="current-category">Categoria:</label>
-                                    <select id="current-category" class="form-control ui-autocomplete-input" name="category"></select>
+                                    <label>Categoria</label>
+                                    <select id="current-category" class="form-control form-control-sm">
+                                    </select>
                                 </div>
                                 <div class="form-group">
                                     <label for="product">Buscar Producto</label>
@@ -79,6 +80,16 @@
                                     <label for="user">Vendedor: </label>
                                     <input id="user" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI"/>
                                 </div>
+                                <div class="form-group">
+                                    <label>Atributo</label>
+                                    <select id="current-attribute" class="form-control form-control-sm">
+                                    </select>
+                                </div>
+                                <div class="form-group">
+                                    <label>Valor del Atributo</label>
+                                    <select id="current-attribute-value" class="form-control form-control-sm">
+                                    </select>
+                                </div>
                             </div>
                         </div>
                     </div>
@@ -104,9 +115,9 @@
                 <th data-field="date_create" data-sortable="true">Fecha</th>
                 <th data-field="journal_name" data-sortable="true">Formas Pago</th>
                 <th data-field="partner_name" data-sortable="true">Cliente</th>
-                <th data-field="ean_product" data-sortable="true">Cod. Barra</th>
-                <th data-field="name" >Producto</th>
-                <th data-field="categ_name" data-sortable="true">Categoria</th>
+                <th data-field="ean13" data-sortable="true">Cod. Barra</th>
+                <th data-field="product_name" >Producto</th>
+                <th data-field="category_name" data-sortable="true">Categoria</th>
                 <th data-field="quantity" data-sortable="true" data-align="right">Cant.</th>
                 <th data-field="price_unity" data-sortable="true" data-align="right">Precio Venta</th>
                 <th data-field="standar_price" data-sortable="true" data-align="right">Precio Costo</th>

+ 16 - 1
static/src/reports/report_ventas_pos_orders.xml

@@ -55,10 +55,25 @@
                         <div class="panel panel-default">
                             <div class="panel-heading">Características</div>
                             <div class="panel-body">
+                                <div class="form-group">
+                                    <label>Categoria</label>
+                                    <select id="current-category" class="form-control form-control-sm">
+                                    </select>
+                                </div>
                                 <div class="form-group">
                                     <label for="product">Buscar Producto</label>
                                     <input id="product" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ Referencia/ Codigo de barras"/>
                                 </div>
+                                <div class="form-group">
+                                    <label>Atributo</label>
+                                    <select id="current-attribute" class="form-control form-control-sm">
+                                    </select>
+                                </div>
+                                <div class="form-group">
+                                    <label>Valor del Atributo</label>
+                                    <select id="current-attribute-value" class="form-control form-control-sm">
+                                    </select>
+                                </div>
                                 <div class="form-group">
                                     <label for="partner">Buscar Cliente:</label>
                                     <input id="partner" type="text" class="form-control ui-autocomplete-input" autocomplete="off" placeholder="Nombre/ CI/ Ruc"/>
@@ -91,7 +106,7 @@
                 <th data-field="ref" data-sortable="true">Venta</th>
                 <th data-field="date_order" data-sortable="true">Fecha</th>
                 <!-- <th data-field="category_name" data-sortable="true" >Categoria</th>-->
-                <th data-field="partner">Cliente</th>
+                <th data-field="partner" data-sortable="true">Cliente</th>
                 <th data-field="product_name" data-sortable="true">Productos</th>
                 <th data-field="qty" data-sortable="true" data-align="right">Cantidad</th>
                 <th data-field="price_unit" data-sortable="true" data-align="right">Precio Venta</th>