Procházet zdrojové kódy

Agregar informe de utilidad de ventas por vendedor

sebas před 4 roky
revize
f77e6f9278

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+import controllers
+import models

binární
__init__.pyc


+ 24 - 0
__openerp__.py

@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+{
+    'name': "Eiru Reports - Imperio",
+    'author': "Eiru",
+    'category': 'report',
+    'version': '0.1',
+    'depends': [
+        'base',
+        'product',
+        'account',
+        'stock',
+        'eiru_assets',
+        'eiru_reports',
+    ],
+    'qweb': [
+        'static/src/xml/*.xml',
+        'static/src/reports/*.xml'
+    ],
+    'data': [
+        'templates.xml',
+        'views/actions.xml',
+        'views/menus.xml',
+    ],
+}

+ 2 - 0
controllers.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from openerp import http

binární
controllers.pyc


+ 118 - 0
models.py

@@ -0,0 +1,118 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields, api
+
+class AccountInvoice(models.Model):
+	_inherit = 'account.invoice'
+
+	############################################################
+	#	ACCOUNT INVOICE
+	############################################################
+
+	@api.model
+	def getAccountInvoiceDental(self,domain):
+		AccountInvoice = self.env['account.invoice'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for invoice in AccountInvoice:
+			values.append({
+				'id': invoice.id,
+				'type': invoice.type,
+				'state': invoice.state,
+				'number': invoice.number,
+				'journal_id': [
+					invoice.journal_id.id,
+					invoice.journal_id.name
+				],
+				'invoice_currency': [
+					invoice.currency_id.id,
+					invoice.currency_id.name,
+					invoice.currency_id.rate
+				],
+				'company_currency': [
+					invoice.company_id.currency_id.id,
+					invoice.company_id.currency_id.name,
+					invoice.company_id.currency_id.rate
+				],
+				'date_invoice': invoice.date_invoice,
+				'partner_id': [
+					invoice.partner_id.id,
+					invoice.partner_id.name,
+				],
+				'supplier_invoice_number': invoice.supplier_invoice_number,
+				'user_id': [
+					invoice.user_id.id,
+					invoice.user_id.name
+				],
+                'period_id': [
+                	invoice.period_id.id,
+                	invoice.period_id.name
+                ],
+				'origin': invoice.origin,
+				'reference': invoice.reference,
+                'amount_untaxed': invoice.amount_untaxed,
+                'residual': invoice.residual,
+                'amount_tax': invoice.amount_tax,
+				'amount_total': invoice.amount_total,
+				'amount_untaxed_currency': invoice.amount_untaxed * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'residual_currency': invoice.residual * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'amount_tax_currency': invoice.amount_tax * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'amount_total_currency': invoice.amount_total * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'comment' : invoice.comment,
+			})
+
+		return values
+
+class AccountInvoiceLine(models.Model):
+	_inherit = 'account.invoice.line'
+
+	############################################################
+	#	ACCOUNT INVOICE LINE
+	############################################################
+
+	@api.model
+	def getAccountInvoiceLineDental(self,domain):
+		AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for line in AccountInvoiceLine:
+			values.append({
+				'id': line.id,
+				'name' : line.name,
+				'invoice_id':line.invoice_id.id,
+				'journal_id' : line.invoice_id.journal_id.id,
+				'product_id': {
+					'id' : line.product_id.id,
+					'name' : line.product_id.name,
+					'standard_price' : line.product_id.standard_price,
+					'default_code' : line.product_id.default_code,
+					'ean13' : line.product_id.ean13,
+					'categ_id' : line.product_id.categ_id.name,
+				},
+				'quantity' : line.quantity,
+				'price_unit' : line.price_unit,
+			})
+
+		return values
+
+class AccountVoucher(models.Model):
+	_inherit = 'account.voucher'
+
+	############################################################
+	#	ACCONT VOUCHER
+	############################################################
+
+	@api.model
+	def getAccountVoucherDental(self,domain):
+		AccountVoucher = self.env['account.voucher'].search(domain)
+		values = []
+		for voucher in AccountVoucher:
+			values.append({
+				'id': voucher.id,
+				'number':voucher.number,
+				'journal_id': voucher.journal_id.id,
+				'amount': voucher.amount,
+				'reference' : voucher.reference,
+			})
+
+		return values

binární
models.pyc


binární
static/description/icon.png


+ 99 - 0
static/src/css/custom.css

@@ -0,0 +1,99 @@
+.bootstrap-table .table > tbody > tr.groupBy {
+    cursor: pointer;
+    background: #ff0000;
+}
+
+.bootstrap-table .table > tbody > tr.groupBy.expanded {
+    background: #ff0000;
+
+}
+
+.bootstrap-table .table > tbody > tr.hidden + tr.detail-view {
+    display: none;
+      background: #ff0000;
+}
+
+.myButton{
+    background: #0288d1 !important;
+    color: white !important;
+    height: 34px !important;
+    border: 1px solid #0288d1 !important;
+    background-image: -webkit-linear-gradient(top, #0288d1, #084B8A) !important;
+}
+.myButton{
+    background: #d9534f !important;
+    /* background: #d9534f !important; */
+    /* color: #37474f !important; */
+    color: #fff !important;
+    height: 34px !important;
+    /* border: 1px solid #bdbdbd !important; */
+    /* border: 1px solid #428bca !important; */
+    border: none !important;
+}
+
+.dropdown-menu > li > a {
+    color: #37474f !important;
+}
+
+.dropdown-menu > .active > a {
+    color:#fff !important;
+    background-color: #d9534f !important;
+}
+
+.detail-icon {
+    color: #e57373 !important;
+}
+
+.pagination > .active > a{
+    color:#fff !important;
+    background-color: #d9534f !important;
+    border-color: #d9534f !important;
+}
+
+.filter-style {
+    padding-top: 10px;
+}
+
+.sale-button {
+    color: #fff !important;
+    background: #81c784;
+    border-color: #81c784;
+}
+.sale-button:hover{
+    color: #fff !important;
+    background: #81c784;
+    border-color: #81c784;
+}
+
+.purchase-button {
+    color: #fff !important;
+    background: #ffb74d;
+    border-color: #ffb74d;
+}
+.purchase-button:hover{
+    color: #fff !important;
+    background: #ffb74d;
+    border-color: #ffb74d;
+}
+
+.expense-button {
+    color: #fff !important;
+    background: #e57373;
+    border-color: #e57373;
+}
+.expense-button:hover{
+    color: #fff !important;
+    background: #e57373;
+    border-color: #e57373;
+}
+
+.balance-button {
+    color: #fff !important;
+    background: #0288d1;
+    border-color: #0288d1;
+}
+.balance-button:hover{
+    color: #fff !important;
+    background: #0288d1;
+    border-color: #0288d1;
+}

+ 196 - 0
static/src/js/group_by.js

@@ -0,0 +1,196 @@
+!function($) {
+  window.handler = new Handler();
+
+  function Handler(){
+    'use strict';
+
+    var initBodyCaller;
+    var  tableGroups = [];
+
+
+
+    // it only does '%s', and return '' when arguments are undefined
+    var sprintf = function (str) {
+        var args = arguments,
+            flag = true,
+            i = 1;
+
+        str = str.replace(/%s/g, function () {
+            var arg = args[i++];
+
+            if (typeof arg === 'undefined') {
+                flag = false;
+                return '';
+            }
+            return arg;
+        });
+        return flag ? str : '';
+    };
+
+    var groupBy = function (array , f) {
+		var groups = {};
+		array.forEach(function(o) {
+			var group = f(o);
+			groups[group] = groups[group] || [];
+			groups[group].push(o);
+		});
+
+		return groups;
+    };
+
+    $.extend($.fn.bootstrapTable.defaults, {
+        groupBy: false,
+        groupByField: ''
+    });
+
+    var BootstrapTable = $.fn.bootstrapTable.Constructor,
+        _initSort = BootstrapTable.prototype.initSort,
+        _initBody = BootstrapTable.prototype.initBody;
+
+
+    BootstrapTable.prototype.initSort = function () {
+        _initSort.apply(this, Array.prototype.slice.apply(arguments));
+
+        var that = this;
+
+        if ((this.options.groupBy) && (this.options.groupByField !== '')) {
+
+            if ((this.options.sortName != this.options.groupByField)) {
+            	this.data.sort(function(a, b) {
+                    return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
+                });
+            }
+
+            var that = this;
+            var groups = groupBy(that.data, function (item) {
+                return [item[that.options.groupByField]];
+            });
+
+            var index = 0;
+            var count;
+
+
+            $.each(groups, function(key, value) {
+                tableGroups.push({
+                    id: index,
+                    name: key
+                });
+
+
+                value.forEach(function(item) {
+                    if (!item._data) {
+                        item._data = {};
+                    }
+
+                    item._data['parent-index'] = index;
+                });
+
+                index++;
+            });
+
+
+      }
+    }
+
+    BootstrapTable.prototype.initBody = function () {
+        initBodyCaller = true;
+        _initBody.apply(this, Array.prototype.slice.apply(arguments));
+
+        if ((this.options.groupBy) && (this.options.groupByField !== '')) {
+            var that = this,
+                checkBox = false,
+                visibleColumns = 0;
+
+            this.columns.forEach(function(column) {
+                if (column.checkbox) {
+                	checkBox = true;
+                } else {
+                    if (column.visible) {
+                        visibleColumns++;
+                    }
+                }
+            });
+
+
+        	tableGroups.forEach(function(item){
+                var html = [];
+
+                html.push(sprintf('<tr class="info groupBy" data-group-index="%s">', item.id));
+
+
+                html.push('<td style="font-weight: bold; text-align: center;"',
+                	sprintf(' colspan="%s"', visibleColumns),
+                    '>', item.name, '</td>'
+                );
+
+                html.push('</tr>');
+
+                that.$body.find('tr[data-parent-index='+item.id+']:first').before($(html.join('')));
+            });
+
+
+            this.$body.find('[name="btSelectGroup"]').each(function() {
+                var self = $(this);
+            });
+
+            this.$container.off('click', '.groupBy')
+                .on('click', '.groupBy', function() {
+                    $(this).toggleClass('expanded');
+                	that.$body.find('tr[data-parent-index='+$(this).closest('tr').data('group-index')+']').toggleClass('hidden');
+                });
+
+            this.$container.off('click', '[name="btSelectGroup"]')
+                .on('click', '[name="btSelectGroup"]', function (event) {
+                	event.stopImmediatePropagation();
+
+                	var self = $(this);
+                    var checked = self.prop('checked');
+                    that[checked ? 'checkGroup' : 'uncheckGroup']($(this).closest('tr').data('group-index'));
+                });
+        }
+
+        initBodyCaller = false;
+        this.updateSelected();
+    };
+
+    BootstrapTable.prototype.getGroupSelections = function (index) {
+        var that = this;
+
+        return $.grep(this.data, function (row) {
+            return (row[that.header.stateField] && (row._data['parent-index'] === index));
+        });
+    };
+
+    BootstrapTable.prototype.checkGroup = function (index) {
+        this.checkGroup_(index, true);
+    };
+
+    BootstrapTable.prototype.uncheckGroup = function (index) {
+        this.checkGroup_(index, false);
+    };
+
+    BootstrapTable.prototype.checkGroup_ = function (index, checked) {
+        var rows;
+        var filter = function() {
+            return ($(this).closest('tr').data('parent-index') === index);
+        };
+
+        if (!checked) {
+            rows = this.getGroupSelections(index);
+        }
+
+        this.$selectItem.filter(filter).prop('checked', checked);
+
+
+        this.updateRows();
+
+        if (checked) {
+            rows = this.getGroupSelections(index);
+        }
+        this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
+    };
+  }
+
+
+
+}(jQuery);

+ 26 - 0
static/src/js/main.js

@@ -0,0 +1,26 @@
+openerp.eiru_reports_imperio= function (instance) {
+    "use strict";
+
+    var reporting = instance.eiru_reports_imperio;
+
+    reporting_base(instance,reporting);
+
+    try {
+        group_by_pdf(reporting);
+        report_seller(reporting);
+        report_sale_utility_vendor(reporting);
+    } catch (e) {
+        // ignorar error
+    }
+
+
+    // Rendicion de venta por vendedor
+
+     instance.web.client_actions.add('eiru_reports_imperio.seller_action', 'instance.eiru_reports_imperio.ReportSellerWidget');
+
+    //  venta agrupado por vendedor
+
+    instance.web.client_actions.add('eiru_reports_imperio.sale_utility_vendor_action', 'instance.eiru_reports_imperio.ReportSaleUtilityVendorWidget');
+
+
+}

+ 148 - 0
static/src/js/pdf.js

@@ -0,0 +1,148 @@
+function group_by_pdf(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPdfWidget = reporting.Base.extend({
+      drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
+      var self = this;
+      var base64Img = 'data:image/png;base64,' + ResCompany.logo;
+      var hoy = moment().format('DD/MM/YYYY');
+      var totalPagesExp = "{total_pages_count_string}";
+      var pdfDoc = new jsPDF(pdf_type);
+      var y_position = 27;
+      var y_position2 = 27;
+
+      //LOGO
+      pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
+
+      //FECHA
+      pdfDoc.setFontSize(13);
+      pdfDoc.setFontStyle('normal');
+      pdfDoc.setTextColor(40)
+      pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
+
+      //TITULO
+      pdfDoc.setFontSize(15);
+      pdfDoc.setFontStyle('bold');
+      pdfDoc.setTextColor('#0288d1');
+      pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
+        halign: 'right',
+        valign: 'middle'
+      });
+      pdfDoc.setLineWidth(0.5);
+      pdfDoc.setDrawColor('#424242');
+      pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
+
+      var i=0;
+      if(pdf_type == 'l'){
+        var col1_title = 15;
+        var col1_value = 55;
+        var col2_title = 150;
+        var col2_value = 190;
+      }
+      else{
+        var col1_title = 10;
+        var col1_value = 50;
+        var col2_title = 110;
+        var col2_value = 150;
+      }
+      if(filter.length >0){
+        _.each(filter,function(item){
+          if(i<4){
+            self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,y_position);
+            y_position = y_position + 5;
+          }else{
+            self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
+            y_position2 = y_position2 + 5;
+          }
+            i++;
+        });
+        pdfDoc.setLineWidth(0.5);
+        pdfDoc.setDrawColor('#424242');
+
+        if(y_position >= y_position2){
+          y_position = y_position;
+          pdfDoc.line(10, y_position, pdfDoc.internal.pageSize.getWidth() - 10 , y_position);
+        }else{
+          y_position = y_position2;
+          pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
+        }
+      }
+
+
+      pdfDoc.autoTable(getColumns, row, {
+          showHeader: 'firstPage',
+          startY: y_position + 5,
+          theme: 'grid',
+          styles: {
+              overflow: 'linebreak',
+              columnWidth: 'auto',
+              fontSize: 7,
+          },
+          headerStyles: {
+              fillColor: [76, 133, 248],
+              fontSize: 8
+          },
+          columnStyles: pdf_columnStyles,
+          margin: { horizontal: 7},
+
+          drawCell: function(cell, opts) {
+              var rows = opts.table.rows;
+              if (opts.row.index == rows.length - 1) {
+                pdfDoc.setFontStyle('bold');
+              }
+              if(opts.row.raw.key == 'categoria'){
+                pdfDoc.setFontStyle('bold');
+                pdfDoc.setFillColor(204, 204, 204);
+              }
+          },
+
+          addPageContent: function (data) {
+
+          //FOOTER
+              var str = "Página " + data.pageCount;
+              if (typeof pdfDoc.putTotalPages === 'function') {
+                  str = str + " de " + totalPagesExp;
+              }
+              pdfDoc.setFontSize(9);
+              pdfDoc.setFontStyle('bold');
+              pdfDoc.setTextColor(40);
+              var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
+              pdfDoc.autoTableText(str, pdfDoc.internal.pageSize.getWidth() - 35, pageHeight - 5, {
+                halign: 'rigth',
+                valign: 'middle'
+              });
+          }
+      });
+      if (typeof pdfDoc.putTotalPages === 'function') {
+          pdfDoc.putTotalPages(totalPagesExp);
+      }
+      row.pop();
+      if(model.printer_bridge){
+          var data = pdfDoc.output('datauristring');
+          model.printer_bridge.print(data);
+          return;
+      }
+      pdfDoc.save(pdf_name + hoy + '.pdf');
+    },
+
+    addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
+      pdfDoc.setFontSize(10);
+      pdfDoc.setTextColor('#424242');
+      pdfDoc.setFontStyle('bold');
+      pdfDoc.autoTableText(title+':', x_position_title, y_position, {
+        halign: 'left',
+        valign: 'middle'
+      });
+      pdfDoc.setFontSize(10);
+      pdfDoc.setTextColor('#424242');
+      pdfDoc.setFontStyle('normal');
+      pdfDoc.autoTableText(value, x_position_value, y_position, {
+        halign: 'left',
+        valign: 'middle'
+      });
+    },
+        //end test
+    });
+}

+ 22 - 0
static/src/js/reporting_base.js

@@ -0,0 +1,22 @@
+function reporting_base (instance, widget) {
+    "use strict";
+
+    widget.Base = instance.Widget.extend({
+
+        position: 0,
+
+        init: function (parent, position) {
+            this._super(parent);
+            this.position = position || this.position;
+        },
+        start: function () {
+            
+        },
+        getPosition: function () {
+            return this.position;
+        },
+        setPosition: function (position) {
+            this.position = position;
+        }
+    });
+}

+ 802 - 0
static/src/js/reports/report_sale_utility_vendor.js

@@ -0,0 +1,802 @@
+function report_sale_utility_vendor(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportSaleUtilityVendorWidget = reporting.Base.extend({
+        template: 'ReportSaleUtilityVendor',
+        rowsData :[],
+        content :[],
+
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #generate' : 'fetchGenerate',
+            'click-row.bs.table #table' : 'clickAnalysisDetail',
+            'change #current-company' : 'updateSelections',
+            'change #current-store' : 'updateJournalSelections',
+            'change #current-date' : 'ShowDateRange',
+            'change #current-period': 'updatePeriodSelections',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            if(date == 'range'){
+                self.$el.find('.datepicker').css('display','block');
+            }
+            if(date != 'range'){
+                self.$el.find('.datepicker').css('display','none');
+            }
+
+        },
+
+        clickAnalysisDetail: function(e, row, $element,field){
+            if (field == 'product_name'){
+                this.do_action({
+                    name:"Producto",
+                    type: 'ir.actions.act_window',
+                    res_model: "product.product",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.product_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.product_id,
+                });
+            }
+
+            if (field == 'invoice_name'){
+                this.do_action({
+                    name:"Factura",
+                    type: 'ir.actions.act_window',
+                    res_model: "account.invoice",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.invoice_id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.invoice_id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchResCompany().then(function (ResCompany) {
+                return ResCompany;
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+                if(ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                return self.fetchResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                if(ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                return self.fetchAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                if(AccountJournal.length > 0){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todos los vendedores</option>');
+                    _.each(AccountJournal,function(item){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                return self.fetchAccountPeriod();
+            }).then(function(AccountPeriod){
+                self.AccountPeriod = AccountPeriod;
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' +  item.id + '">' + item.name + '</option>');
+                });
+                return self.fetchProductCategory();
+          }).then(function(ProductCategory){
+              self.ProductCategory = ProductCategory;
+              if(ProductCategory.length > 1){
+                  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>');
+                  });
+              }else{
+                  self.$el.find('.category').css('display','none');
+              }
+                return self.fetchResCurrency();
+            }).then(function(ResCurrency){
+                self.ResCurrency = ResCurrency;
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+
+            this.fetchAccountInvoice().then(function(AccountInvoice) {
+                return AccountInvoice;
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceLine();
+            }).then(function (AccountInvoiceLine){
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.BuildTable();
+            });
+        },
+
+
+
+        /*====================================================================
+            RES COMPANY
+        ====================================================================*/
+        fetchResCompany: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.web.Model('res.company');
+            var field=['id','name','currency_id','logo'];
+            currency.query(field).filter().all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES STORE
+        ====================================================================*/
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id','name','company_id'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT JOURNAL
+        ====================================================================*/
+        fetchAccountJournal: function(){
+            var self = this;
+            var domain = [['active','=',true],['type','=','sale']];
+            var AccountJournal = new model.web.Model('account.journal');
+            return AccountJournal.call('getAccountJournal',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*=====================================================================
+            ACCOUNT PERIOD
+        =====================================================================*/
+        fetchAccountPeriod: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['special','=',false]];
+            var field =['id', 'name', 'date_start','date_stop','company_id'];
+            var AccountPeriod = new model.web.Model('account.period');
+            AccountPeriod.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+        PRODUCT CATEGORY
+    ====================================================================*/
+    fetchProductCategory: function () {
+        var self = this;
+        var domain = [];
+        var ProductCategory = new model.web.Model('product.category');
+        return ProductCategory.call('getProductCategory',[domain], {
+            context: new model.web.CompoundContext()
+        });
+    },
+
+
+        /*====================================================================
+            RES CURRENCY
+        ====================================================================*/
+        fetchResCurrency : function(){
+            var self = this;
+            var defer = $.Deferred();
+            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;
+        },
+
+        /*====================================================================
+            ACCOUNT INVOICE
+        ====================================================================*/
+        fetchAccountInvoice: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            var period = self.$el.find('#current-period').val();
+            var company = self.$el.find('#current-company').val();
+            var journal = self.$el.find('#current-journal').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if(store && store != 9999999){
+                var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+                    return item.store_ids == store;
+                }), function(map){
+                    return map.id;
+                });
+            }else{
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+            }
+
+            var domain = [
+                ['state', 'in',['open','paid']],
+                ['type', '=', 'out_invoice'],
+                ['journal_id','in',journal_ids],
+            ];
+
+            if(journal && journal != 9999999){
+                domain.push(['journal_id','=',parseInt(journal)]);
+            }
+
+            if(company && company != 9999999){
+                domain.push(['company_id','=',parseInt(company)]);
+            }
+
+            if(period && period != 9999999){
+                domain.push(['period_id','=',parseInt(period)]);
+            }
+
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','>=',date]);
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','<=',date]);
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',today]);
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',yesterday]);
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    domain.push(['date_invoice','like',currentMonth]);
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    domain.push(['date_invoice','like',lastMonth]);
+                }
+            }
+
+            var AccountInvoice = new model.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoiceDental',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+
+        /*====================================================================
+                  ACCOUNT INVOICE LINE
+              ====================================================================*/
+              fetchAccountInvoiceLine: function () {
+                  var self = this;
+                  var categ_ids = [];
+                  var category = self.$el.find('#current-category').val();
+                  var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
+                      return item.id;
+                  }));
+                  var domain = [
+                      ['invoice_id','in',invoice_ids],
+                  ];
+
+                  if(category){
+                      var category_ids = _.map(_.filter(self.ProductCategory,function (item) {
+                          return item.id == category;
+                      }), function(map){
+                          return map.id;
+                      });
+
+
+                      categ_ids =  _.map(_.filter(self.ProductCategory,function (item) {
+                          return _.contains(category_ids, item.parent_id[0]) || item.id == category;
+                      }), function(map){
+                          return map.id;
+                      });
+                  };
+
+                  if(category && category != 9999999){
+                      domain.push(['product_id.categ_id','in',categ_ids]);
+                  }
+
+                  var AccountInvoiceLine = new model.web.Model('account.invoice.line');
+                  return AccountInvoiceLine.call('getAccountInvoiceLineDental',[domain], {
+                      context: new model.web.CompoundContext()
+                  });
+              },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_ids){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
+
+        /*====================================================================
+            GET RES COMPANY
+        ====================================================================*/
+        getResCompany: function (id) {
+            var self = this;
+            return _.filter(self.ResCompany,function (item) {
+                return item.id == id;
+            })
+        },
+
+        /*====================================================================
+            GET RES CURRENCY BASE
+        ====================================================================*/
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+
+        /*====================================================================
+            GET ACCOUNT INVOICE
+        ====================================================================*/
+        getAccountInvoice: function (id) {
+          var self = this;
+          return _.filter(self.AccountInvoice,function (item) {
+            return item.journal_id[0] === id;
+          });
+        },
+
+      /*====================================================================
+           GET ACCOUNT INVOICE LINE
+       ====================================================================*/
+       getAccountInvoiceLine: function (id) {
+         var self = this;
+         return _.filter(self.AccountInvoiceLine, function(item){
+             return item.invoice_id === id;
+         });
+       },
+
+        /*====================================================================
+            BUILD
+        ====================================================================*/
+        BuildTable: function(){
+          var self = this;
+          var data = [];
+          var company = $('#current-company').val();
+
+          if(company && company != 9999999){
+            var ResCompany = self.getResCompany(company).shift();
+            var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+          }else{
+            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+          };
+
+          var AccountJournal = self.AccountJournal;
+          _.each(AccountJournal,function(item) {
+
+            var total_price = 0;
+            var total_cost = 0;
+
+            var utility = 0;
+            var porc_utility = 0;
+            var payment_type = '';
+
+            var AccountInvoice = self.getAccountInvoice(item.id);
+            _.each(AccountInvoice,function(item2) {
+              var total_sale = 0;
+
+              var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
+              _.each(AccountInvoiceLine, function(line_item){
+
+                if(line_item.product_id.standard_price != 0){
+                    total_sale = (line_item.price_unit/(1.1));
+                    total_cost = line_item.product_id.standard_price * line_item.quantity;
+                    total_price = total_sale * line_item.quantity;
+                    utility = total_price - total_cost;
+                    porc_utility = (utility/total_cost)*100;
+                }else{
+                  total_sale = (line_item.price_unit/(1.1));
+                  total_cost = line_item.product_id.standard_price * line_item.quantity;
+                  total_price = total_sale * line_item.quantity;
+                  utility = total_price - total_cost;
+                  porc_utility = (0/total_cost)*100;
+                }
+                data.push({
+                  //IDS
+                  id: line_item.id,
+                  product_id : line_item.product_id.id,
+                  invoice_id : item2.id,
+
+                  //DATAS
+                  categ_id : line_item.product_id.categ_id,
+                  date_invoice: moment(item2.date_invoice).format('YYYY-MM-DD'),
+                  invoice_name : item2.number,
+                  product_code : self.valorNull(line_item.product_id.default_code),
+                  barcode : self.valorNull(line_item.product_id.ean13),
+                  product_name : line_item.product_id.name,
+                  item_cost : accounting.formatMoney(line_item.product_id.standard_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  item_price : accounting.formatMoney(total_sale,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  qty : line_item.quantity,
+                  total_price : accounting.formatMoney(total_price,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  total_cost : accounting.formatMoney(total_cost,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  utility_porcent : accounting.formatNumber((porc_utility),2, ".", ","),
+                  utility : accounting.formatMoney(utility,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                  user_id : self.valorNull(item2.user_id[0]),
+                  user_name : item2.user_id[1],
+
+                  //VALORES SIN FORMATEAR
+                  item_cost_no_format : line_item.product_id.standard_price,
+                  item_price_no_format : total_sale,
+                  total_price_no_format : total_price,
+                  total_cost_no_format : total_cost,
+                  utility_no_format : utility,
+                  utility_porcent_no_format : porc_utility,
+
+                  //TOTAL FOOTER CONFIGURATION
+                  decimal_places : CurrencyBase.decimal_places,
+                  thousands_separator: CurrencyBase.thousands_separator,
+                  decimal_separator: CurrencyBase.decimal_separator,
+
+                });
+              });
+            });
+          });
+
+          self.content = data;
+          self.loadTable(data);
+
+          self.$el.find('.report-form').css('display','block');
+          self.$el.find('.search-form').unblock();
+          self.$el.find('.report-form').unblock();
+        },
+
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = self.getResCompany(company).shift();
+                var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+            }else{
+                ResCompany = self.ResCompany[0];
+                var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            }
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var total_price = totalPriceFormatter(row);
+            var total_cost = totalCostFormatter(row);
+            var utility = totalUtilityFormatter(row);
+            var utility_porcent_no_format = totalUtilityPorcFormatter(row);
+
+            row.push({
+                date_invoice: 'Totales',
+                total_price: total_price,
+                total_cost: total_cost,
+                utility:utility,
+                utility_porcent:utility_porcent_no_format,
+            })
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){ return val.field});
+                _.each(_.map(column,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Utilidad por línea de ventas por Vendedores';
+                var pdf_type = 'l';
+                var pdf_name = 'utilidad_venta_vendedor';
+                var pdf_columnStyles =  {
+
+                  date_invoice: {columnWidth: 21, halign:'center'},
+                  invoice_name : {columnWidth: 24, halign:'center'},
+                  product_code : {columnWidth: 21, halign:'center'},
+                  barcode : {columnWidth: 15, halign:'center'},
+                  product_name : {columnWidth: 38, halign:'center'},
+                  item_cost : {columnWidth: 21, halign:'right'},
+                  item_price : {columnWidth: 21, halign:'right'},
+                  qty : {columnWidth: 16, halign:'center'},
+                  total_price : {columnWidth: 21, halign:'right'},
+                  total_cost : {columnWidth: 21, halign:'right'},
+                  utility : {columnWidth: 21, halign:'right'},
+                  utility_porcent : {columnWidth: 16, halign:'center'},
+                  user_name : {columnWidth: 23, halign:'center'},
+
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new reporting.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter,
+                );
+            }
+        },
+        getFilter: function(){
+          var self = this;
+          var company = self.$el.find('#current-company').val();
+          var store = self.$el.find('#current-store').val();
+          var journal = self.$el.find('#current-journal').val();
+          var category = self.$el.find('#current-category').val();
+          var period = self.$el.find('#current-period').val();
+          var date = self.$el.find('#current-date').val();
+          var desde = self.$el.find('#from').val();
+          var hasta = self.$el.find('#to').val();
+
+          var filter = [];
+
+          if(company && company){
+            var ResCompany = _.filter(self.ResCompany, function(item){
+              return item.id == company;
+            });
+            filter.push({
+              title:'Empresa',
+              value: ResCompany[0].name,
+            });
+          }
+
+          if(store && store != 9999999){
+            var ResStore =  _.filter(self.ResStore,function (item) {
+                return item.id == store;
+            });
+
+            filter.push({
+                title: 'Sucursal',
+                value:  ResStore[0].name,
+            });
+
+          }
+
+          if(journal && journal != 9999999){
+            var AccountJournal =  _.filter(self.AccountJournal,function (item) {
+                return item.id == journal;
+            });
+            filter.push({
+                 title: 'Vendedor',
+                 value: AccountJournal[0].name,
+               });
+          }
+
+          if(category && category != 9999999){
+            var ProductCategory = _.filter(self.ProductCategory, function(item){
+              return item.id == category;
+            })
+            filter.push({
+                title: 'Categoría',
+                value:  ProductCategory[0].name,
+            });
+          }
+
+          if(period && period != 9999999){
+
+            var AccountPeriod =  _.filter(self.AccountPeriod,function (item) {
+                return item.id == period;
+            });
+            filter.push({
+                 title: 'Periodo',
+                 value:  AccountPeriod[0].name,
+               });
+          }
+
+          if(date && date != 9999999){
+            moment.locale('es', {
+              months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+            });
+
+            if(date == 'range'){
+              filter.push({
+                  title: 'Fecha',
+                  value:  desde +' al '+hasta,
+              });
+
+            }
+            else {
+              if(date == 'today'){
+                  var fecha = moment().format('DD/MM/YYYY');
+              }
+
+              if(date == 'yesterday'){
+                  var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+              }
+              if(date == 'currentMonth'){
+                  var fecha = moment().format('MMMM/YYYY');
+              }
+              if(date == 'lastMonth'){
+                  var fecha = moment().add(-1,'months').format('MMMM/YYYY');
+              }
+
+              filter.push({
+                  title: 'Fecha',
+                  value:  fecha,
+              });
+            }
+          }
+          return filter;
+        },
+
+    });
+}

+ 704 - 0
static/src/js/reports/report_seller.js

@@ -0,0 +1,704 @@
+function report_seller(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportSellerWidget = reporting.Base.extend({
+        template: 'ReportSeller',
+        rowsData :[],
+        content :[],
+
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #generate' : 'fetchGenerate',
+            'change #current-company' : 'updateSelections',
+            'change #current-store' : 'updateJournalSelections',
+            'change #current-date' : 'ShowDateRange',
+            'change #current-period': 'updatePeriodSelections',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            if(date == 'range'){
+                self.$el.find('.datepicker').css('display','block');
+            }
+            if(date != 'range'){
+                self.$el.find('.datepicker').css('display','none');
+            }
+
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fetchResCompany().then(function (ResCompany) {
+                return ResCompany;
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+                if(ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                return self.fetchResUser();
+           }).then(function(ResUser){
+                  self.ResUser = ResUser;
+                  if(ResUser.length > 1){
+                      self.$el.find('#current-user').append('<option value="9999999">Todas los vendedores</option>');
+                      _.each(ResUser,function(item){
+                          self.$el.find('#current-user').append('<option value="' + item.id + '">' + item.name + '</option>');
+                      });
+                  }else{
+                      self.$el.find('.user').css('display','none');
+                  }
+                return self.fetchResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                if(ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                return self.fetchAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                if(AccountJournal.length > 0){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todos los vendedores</option>');
+                    _.each(AccountJournal,function(item){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                return self.fetchAccountPeriod();
+            }).then(function(AccountPeriod){
+                self.AccountPeriod = AccountPeriod;
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' +  item.id + '">' + item.name + '</option>');
+                });
+                return self.fetchResCurrency();
+            }).then(function(ResCurrency){
+                self.ResCurrency = ResCurrency;
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+
+            this.fetchAccountJournal().then(function(AccountJournal) {
+                return AccountJournal;
+            }).then(function (AccountJournal) {
+                self.AccountJournal = AccountJournal;
+                return self.fetchAccountInvoice();
+            }).then(function (AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceLine();
+            }).then(function (AccountInvoiceLine){
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.BuildTable();
+            });
+        },
+
+
+
+        /*====================================================================
+            RES COMPANY
+        ====================================================================*/
+        fetchResCompany: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.web.Model('res.company');
+            var field=['id','name','currency_id','logo'];
+            currency.query(field).filter().all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES STORE
+        ====================================================================*/
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id','name','company_id'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT JOURNAL
+        ====================================================================*/
+        fetchAccountJournal: function(){
+            var self = this;
+            var journal = self.$el.find('#current-journal').val();
+            var domain = [['active','=',true],['type','=','sale']];
+            if(journal && journal != 9999999){
+                domain.push(['id','=',parseInt(journal)]);
+            }
+            var AccountJournal = new model.web.Model('account.journal');
+            return AccountJournal.call('getAccountJournal',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*=====================================================================
+            ACCOUNT PERIOD
+        =====================================================================*/
+        fetchAccountPeriod: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['special','=',false]];
+            var field =['id', 'name', 'date_start','date_stop','company_id'];
+            var AccountPeriod = new model.web.Model('account.period');
+            AccountPeriod.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES CURRENCY
+        ====================================================================*/
+        fetchResCurrency : function(){
+            var self = this;
+            var defer = $.Deferred();
+            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;
+        },
+
+
+        fetchResUser: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','store_id'];
+            var domain = [];
+            var ResUser = new model.web.Model('res.users');
+            ResUser.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+
+        getAccountInvoice:function(id) {
+            var self = this;
+            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                return inv.user_id === id && inv.type == 'out_invoice';
+            }));
+        },
+
+        /*====================================================================
+            ACCOUNT INVOICE
+        ====================================================================*/
+        fetchAccountInvoice: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            var period = self.$el.find('#current-period').val();
+            var company = self.$el.find('#current-company').val();
+
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            // if(store && store != 9999999){
+            //     var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+            //         return item.store_ids == store;
+            //     }), function(map){
+            //         return map.id;
+            //     });
+            // }else{
+            //     var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+            //         return item.id;
+            //     }));
+            // }
+
+            var domain = [
+                ['state', 'in',['open','paid']],
+                ['type', '=', 'out_invoice'],
+            ];
+
+            if(company && company != 9999999){
+                domain.push(['company_id','=',parseInt(company)]);
+            }
+
+            if(period && period != 9999999){
+                domain.push(['period_id','=',parseInt(period)]);
+            }
+
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','>=',date]);
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','<=',date]);
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',today]);
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',yesterday]);
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    domain.push(['date_invoice','like',currentMonth]);
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    domain.push(['date_invoice','like',lastMonth]);
+                }
+            }
+
+            var AccountInvoice = new model.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoiceDental',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+
+        /*====================================================================
+                  ACCOUNT INVOICE LINE
+        ====================================================================*/
+        fetchAccountInvoiceLine: function () {
+            var self = this;
+            var invoice_ids = _.flatten(_.map(self.AccountInvoice, function (item) {
+                  return item.id;
+            }));
+            var domain = [
+                  ['invoice_id','in',invoice_ids],
+            ];
+            var AccountInvoiceLine = new model.web.Model('account.invoice.line');
+                return AccountInvoiceLine.call('getAccountInvoiceLineDental',[domain], {
+                    context: new model.web.CompoundContext()
+                });
+            },
+
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursellers</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_ids){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
+
+        /*====================================================================
+            GET RES COMPANY
+        ====================================================================*/
+        getResCompany: function (id) {
+            var self = this;
+            return _.filter(self.ResCompany,function (item) {
+                return item.id == id;
+            })
+        },
+
+        /*====================================================================
+            GET RES CURRENCY BASE
+        ====================================================================*/
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+
+        /*====================================================================
+            GET ACCOUNT INVOICE
+        ====================================================================*/
+        getAccountInvoice: function (id) {
+          var self = this;
+          return _.filter(self.AccountInvoice,function (item) {
+            return item.user_id[0] === id;
+          });
+        },
+
+      /*====================================================================
+           GET ACCOUNT INVOICE LINE
+       ====================================================================*/
+       getAccountInvoiceLine: function (id) {
+         var self = this;
+         return _.filter(self.AccountInvoiceLine, function(item){
+             return item.invoice_id === id;
+         });
+       },
+
+
+      BuildTable: function() {
+          var self = this;
+          var ranking = [];
+          var data = [];
+          var company = $('#current-company').val();
+
+          if(company && company != 9999999){
+            var ResCompany = self.getResCompany(company).shift();
+            var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+          }else{
+            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+          };
+
+          var ResUser = self.ResUser;
+          _.each(ResUser, function (item) {
+
+              var AccountInvoice = self.getAccountInvoice(item.id);
+
+              // var AccountInvoice = self.getAccountInvoice(item.id);
+              // _.each(AccountInvoice,function(item2) {
+
+            //   var AccountInvoiceLine = self.getAccountInvoiceLine(item2.id);
+            //   _.each(AccountInvoiceLine, function(line_item){
+            //     total_cost = total_cost + (line_item.product_id.standard_price * line_item.quantity);
+            //   });
+            // });
+
+              var account_invoice_amount = 0;
+              if(AccountInvoice.length > 0){
+                  account_invoice_amount = _.reduce(_.map(AccountInvoice,function(item) {
+                          return item.amount_total;
+                      }),function(memo, num) {
+                          return memo + num
+                  },0);
+              }
+
+              if(account_invoice_amount > 0){
+                    data.push({
+                         name: item.name,
+                         total_amount : accounting.formatMoney(account_invoice_amount,'', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+                         total_amount_no_format : account_invoice_amount,
+
+                         decimal_places : CurrencyBase.decimal_places,
+                         thousands_separator: CurrencyBase.thousands_separator,
+                         decimal_separator: CurrencyBase.decimal_separator,
+                    });
+               }
+          });
+                self.content = data;
+                self.loadTable(data);
+                self.$el.find('.report-form').css('display','block');
+                self.$el.find('.search-form').unblock();
+                self.$el.find('.report-form').unblock();
+      },
+
+
+
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = self.getResCompany(company).shift();
+                var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+            }else{
+                ResCompany = self.ResCompany[0];
+                var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            }
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var total_amount = totalAmountFormatter(row);
+            // var total_cost = totalCostFormatter(row);
+            // var total_utility = totalUtilityFormatter(row);
+            // var total_cost_percent = totalCostPercentFormatter(row);
+            // var total_sale_percent = totalSalePercentFormatter(row);
+
+            row.push({
+                name: 'Totales',
+                total_amount: total_amount,
+                // total_cost: total_cost,
+                // utility: total_utility,
+                // cost_percent: total_cost_percent,
+                // sale_percent: total_sale_percent,
+
+            })
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){ return val.field});
+                _.each(_.map(column,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Venta/Costo/Utilidad por vendedores';
+                var pdf_type = '';
+                var pdf_name = 'venta_costo_utilidad_por_vendedores_';
+                var pdf_columnStyles =  {
+                  name : {columnWidth: 30, halign:'left'},
+                  total_amount : {columnWidth: 25, halign:'right'},
+                  // total_cost : {columnWidth: 25, halign:'right'},
+                  // utility : {columnWidth: 25, halign:'right'},
+                  // cost_percent : {columnWidth: 20, halign:'right'},
+                  // sale_percent : {columnWidth: 20, halign:'right'},
+
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var filter = self.getFilter();
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                    filter,
+                );
+            }
+        },
+        getFilter: function(){
+          var self = this;
+          var company = self.$el.find('#current-company').val();
+          var store = self.$el.find('#current-store').val();
+          var journal = self.$el.find('#current-journal').val();
+          var period = self.$el.find('#current-period').val();
+          var date = self.$el.find('#current-date').val();
+          var desde = self.$el.find('#from').val();
+          var hasta = self.$el.find('#to').val();
+
+          var filter = [];
+
+          if(company && company){
+            var ResCompany = _.filter(self.ResCompany, function(item){
+              return item.id == company;
+            });
+            filter.push({
+              title:'Empresa',
+              value: ResCompany[0].name,
+            });
+          }
+
+          if(store && store != 9999999){
+            var ResStore =  _.filter(self.ResStore,function (item) {
+                return item.id == store;
+            });
+
+            filter.push({
+                title: 'Sucursal',
+                value:  ResStore[0].name,
+            });
+
+          }
+          if(journal && journal != 9999999){
+            var AccountJournal = _.filter(self.AccountJournal, function(item){
+              return item.id == journal;
+            })
+            filter.push({
+                title: 'Vendedor',
+                value:  AccountJournal[0].name,
+            });
+          }
+
+          if(period && period != 9999999){
+
+            var AccountPeriod =  _.filter(self.AccountPeriod,function (item) {
+                return item.id == period;
+            });
+            filter.push({
+                 title: 'Periodo',
+                 value:  AccountPeriod[0].name,
+               });
+          }
+
+          if(date && date != 9999999){
+            moment.locale('es', {
+              months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+            });
+
+            if(date == 'range'){
+              filter.push({
+                  title: 'Fecha',
+                  value:  desde +' al '+hasta,
+              });
+
+            }
+            else {
+              if(date == 'today'){
+                  var fecha = moment().format('DD/MM/YYYY');
+              }
+
+              if(date == 'yesterday'){
+                  var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+              }
+              if(date == 'currentMonth'){
+                  var fecha = moment().format('MMMM/YYYY');
+              }
+              if(date == 'lastMonth'){
+                  var fecha = moment().add(-1,'months').format('MMMM/YYYY');
+              }
+
+              filter.push({
+                  title: 'Fecha',
+                  value:  fecha,
+              });
+            }
+          }
+          return filter;
+        },
+    });
+}

+ 232 - 0
static/src/reports/report_sale_utility_vendor.xml

@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportSaleUtilityVendor">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Utilidad por línea de ventas por Vendedores</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <!-- <div class="col-lg-3 journal filter-style">
+                        <label>Vendedor</label>
+                        <select id="current-journal" class="form-control form-control-sm">
+                        </select>
+                    </div> -->
+                    <div class="col-lg-3 category filter-style">
+                        <label>Categoría</label>
+                        <select id="current-category" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:100%;">
+                  <table id="table"
+                    data-search="true"
+                    data-show-columns="true"
+                    data-pagination="true"
+                    data-page-size="10"
+                    data-toggle="table"
+                    data-toolbar="#toolbar"
+                    data-classes="table table-condensed table-no-bordered"
+                    data-row-style="rowStyle"
+                    data-show-export="true"
+                    data-show-toggle="true"
+                    data-pagination-detail-h-align="left"
+                    data-show-footer="true"
+                    data-footer-style="footerStyle"
+                    data-buttons-class="oe_button oe_form_button myButton"
+                    data-show-pagination-switch="true"
+                    data-search-on-enter-key="true"
+                    data-undefined-text=" "
+                    >
+                    <thead style="background:none;">
+                       <tr>
+                          <th data-field="date_invoice" data-align="center" data-footer-formatter="Totales">Fecha</th>
+                          <th data-field="invoice_name" data-align="center">Factura</th>
+                          <th data-field="product_code" data-align="center">Cod. Producto</th>
+                          <th data-field="barcode" data-align="center">Cod.Barra</th>
+                          <th data-field="product_name" data-align="center" data-cell-style="cellStyle" data-row-style="rowStyle">Producto</th>
+                          <th data-field="item_cost" data-align="right">Costo Unit.</th>
+                          <th data-field="item_price" data-align="right">Venta Unit.</th>
+                          <th data-field="qty" data-align="center">Cant.</th>
+                          <th data-field="total_price" data-footer-formatter="totalPriceFormatter" data-align="right">Total Venta</th>
+                          <th data-field="total_cost" data-footer-formatter="totalCostFormatter" data-align="right">Total Costo</th>
+                          <th data-field="utility" data-footer-formatter="totalUtilityFormatter" data-align="right">Utilidad</th>
+                          <th data-field="utility_porcent" data-footer-formatter="totalUtilityPorcFormatter" data-sortable="true">%</th>
+                          <th data-field="user_name" data-align="left">Vendedor</th>
+                        </tr>
+                      </thead>
+
+                    </table>
+                </div>
+            </div>
+            <script>
+              <!-- function cellStyle(value, row, index,field) {
+                  if (row.key === 'categoria') {
+                      return {
+                          css: {"background": "#bbdefb",  "font-weight": "bold",},
+                      };
+                  }
+                  return false;
+              }
+
+              function rowStyle(row, index) {
+                  if (row.key === 'categoria') {
+                      return {
+                          css: {"background": "#bbdefb",  "font-weight": "bold",},
+                      };
+                  }
+                  return false;
+              } -->
+
+                <!--
+                    TOTAL PRICE
+                -->
+                function totalPriceFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_price_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    TOTAL COST
+                -->
+                function totalCostFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_cost_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    TOTAL UTILITY
+                -->
+                function totalUtilityFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.utility_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    TOTAL UTILITY %
+                -->
+                function totalUtilityPorcFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.utility_porcent_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold",
+                        }
+                    };
+                };
+
+
+            </script>
+        </div>
+    </t>
+</template>

+ 271 - 0
static/src/reports/report_seller.xml

@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportSeller">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Venta/Costo/Utilidad por Vendedores</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 journal filter-style">
+                        <label>Vendedor</label>
+                        <select id="current-journal" class="form-control form-control-sm">
+                        </select>
+                    </div>
+
+                    <div class="col-lg-3 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                  <div class="text-center" style="padding-top:20px;">
+                      <button id="generate" class="myButton" aria-label="Left Align" style="color:#fff;display:none;">
+                        Generar
+                    </button>
+                  </div>
+                  <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button myButton" value="pdf">Imprimir Informe</button>
+                </div>
+                <div class="container" style="width:95%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-height="auto"
+                        data-classes="table table-condensed  table-no-bordered"
+                        data-row-style="rowStyle"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button oe_form_button myButton"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                                <th data-field="name" data-footer-formatter="Totales" data-align="left">Nombre</th>
+                                <!-- <th data-field="total_cash" data-footer-formatter="totalCashFormatter" data-align="right">Total Contado</th>
+                                <th data-field="total_credit" data-footer-formatter="totalCreditFormatter" data-align="right">Total Credito</th> -->
+                                <th data-field="total_amount" data-footer-formatter="totalAmountFormatter" data-align="right">Total Ventas</th>
+                                <th data-field="total_cost" data-footer-formatter="totalCostFormatter" data-align="right">Costo Total</th>
+                                <th data-field="utility" data-footer-formatter="totalUtilityFormatter" data-align="right">Utilidad Ventas</th>
+                                <th data-field="cost_percent" data-footer-formatter="totalCostPercentFormatter" data-align="right">Rent. Costo %</th>
+                                <th data-field="sale_percent" data-footer-formatter="totalSalePercentFormatter" data-align="right">Rent. Venta %</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+
+                <!--
+                    TOTAL CASH
+                -->
+                <!-- function totalCashFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_cash_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                } -->
+
+                <!--
+                    TOTAL CREDIT
+                -->
+                <!-- function totalCreditFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_credit_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                } -->
+
+                <!--
+                    TOTAL AMOUNT
+                -->
+                function totalAmountFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_amount_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    TOTAL COST
+                -->
+                function totalCostFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.total_cost_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    TOTAL UTILITY
+                -->
+                function totalUtilityFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.utility_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+
+                <!--
+                    TOTAL COST PERCENT
+                -->
+                function totalCostPercentFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+
+                    var totalUtility = _.reduce(_.map(rowsTable,function(item){
+                          return (item.utility_no_format);
+                      }), function(memo, num){
+                      return memo + num; },0)
+
+                    var totalCost =  _.reduce(_.map(rowsTable,function(item){
+                          return (item.total_cost_no_format);
+                      }), function(memo, num){
+                      return memo + num; },0)
+
+                    var amount =  totalUtility * 100 / totalCost;
+                    return accounting.formatNumber(amount,2,thousands_separator,decimal_separator) + ' %';
+                }
+
+                <!--
+                    TOTAL SALE PERCENT
+                -->
+                function totalSalePercentFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var totalUtility = _.reduce(_.map(rowsTable,function(item){
+                          return (item.utility_no_format);
+                      }), function(memo, num){
+                      return memo + num; },0)
+
+                    var totalSale =  _.reduce(_.map(rowsTable,function(item){
+                          return (item.total_amount_no_format);
+                      }), function(memo, num){
+                      return memo + num; },0)
+
+                    var amount =  totalUtility * 100 / totalSale;
+                    return accounting.formatNumber(amount,2,thousands_separator,decimal_separator)+' %';
+                }
+
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+            </script>
+        </div>
+    </t>
+</template>

+ 5 - 0
static/src/xml/eiru_reporting.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 5 - 0
static/src/xml/eiru_reporting_base.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    
+</template>

+ 22 - 0
templates.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <template id="eiru_reports_imperio_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+
+                <!-- configuration < main > -->
+                <script type="text/javascript" src="/eiru_reports_imperio/static/src/js/main.js" />
+                <script type="text/javascript" src="/eiru_reports_imperio/static/src/js/reporting_base.js" />
+                <script type="text/javascript" src="/eiru_reports_imperio/static/src/js/pdf.js" />
+
+
+                <!-- rendicion de venta por vendedor -->
+                <script type="text/javascript" src="/eiru_reports_imperio/static/src/js/reports/report_seller.js"/>
+
+                <!-- rendicion de venta por vendedor agrupado-->
+                <script type="text/javascript" src="/eiru_reports_imperio/static/src/js/reports/report_sale_utility_vendor.js"/>
+
+            </xpath>
+        </template>
+    </data>
+</openerp>

+ 16 - 0
views/actions.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+
+		<record id="seller_action" model="ir.actions.client">
+            <field name="name">Utilidad por Ventas - Vendedores</field>
+            <field name="tag">eiru_reports_imperio.seller_action</field>
+    </record>
+
+		<record id="sale_utility_vendor_action" model="ir.actions.client">
+						<field name="name">Utilidad de línea de Venta por Vendedores</field>
+						<field name="tag">eiru_reports_imperio.sale_utility_vendor_action</field>
+		</record>
+
+    </data>
+</openerp>

+ 25 - 0
views/menus.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+      <!--
+       =======================================================================
+           Dental G6
+       =======================================================================
+       -->
+       <menuitem id="utility_parent_menu" name="Imperio" parent="eiru_reports.sale_parent_menu" sequence="10"/>
+
+
+       <menuitem id="seller_menu"
+          parent="utility_parent_menu"
+          name="Venta/Costo/Utilidad por Vendedores"
+          action="seller_action"
+          sequence="1"/>
+
+        <menuitem id="sale_utility_vendor_menu"
+              parent="utility_parent_menu"
+              name="Utilidad por línea de ventas por Vendedores por Producto"
+              action="sale_utility_vendor_action"
+              sequence="6"/>
+
+    </data>
+</openerp>

+ 15 - 0
views/payment_term.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- <openerp>
+  <data>
+    <record model="ir.ui.view" id="view_payment_term_form2">
+      <field name="name">view_payment_term_form2</field>
+      <field name="model">account.payment.term</field>
+      <field name="inherit_id" ref="account.view_payment_term_form" />
+      <field name="arch" type="xml">
+        <field name="active" position="after">
+          <field name="check_credit"/>
+        </field>
+      </field>
+    </record>
+  </data>
+</openerp>  -->