Explorar o código

[ADD] reporte de comision por delivery

deisy %!s(int64=5) %!d(string=hai) anos
pai
achega
e9b82c2b41

BIN=BIN
__init__.pyc


BIN=BIN
controllers.pyc


+ 4 - 1
static/src/js/main.js

@@ -7,11 +7,14 @@ openerp.eiru_reports_baco = function(instance) {
 
   try {
     report_product_ranking_baco(reporting);
+    report_delivery_baco(reporting);
   } catch (e) {
     // ignorar error
   }
 
-  // lista de funcionarios
+
   instance.web.client_actions.add('eiru_reports_baco.product_ranking_baco_action', 'instance.eiru_reports_baco.ReportProductRankingBacoWidget');
+  instance.web.client_actions.add('eiru_reports_baco.delivery_action', 'instance.eiru_reports_baco.ReportDeliveryWidget');
+
 
 }

+ 737 - 0
static/src/js/reports/report_delivery_baco.js

@@ -0,0 +1,737 @@
+function report_delivery_baco(reporting){
+  "use strict";
+
+  var model = openerp;
+
+  reporting.ReportDeliveryWidget = reporting.Base.extend({
+    template: 'ReportDeliveryWidget',
+    rowsData: [],
+    content: [],
+    modules: ['point_of_sale'],
+
+    events: {
+      'click #toolbar > button': 'clickOnAction',
+      'click #generate': 'fetchGenerate',
+      'change #current-company': 'updateSelections',
+      'change #current-period': 'updatePeriodSelections',
+      'change #current-date': 'ShowDateRange',
+    },
+
+    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;
+    },
+
+    checkModel: function(model) {
+      var self = this;
+      return _.filter(self.IrModuleModule, function(item) {
+        return item.name === model
+      });
+    },
+
+    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.fecthIrModuleModule().then(function(IrModuleModule) {
+        return IrModuleModule;
+      }).then(function(IrModuleModule) {
+        self.IrModuleModule = IrModuleModule;
+        return self.fetchResUser();
+      }).then(function(ResUser) {
+        self.ResUser = ResUser;
+        self.fecthCheckType();
+        return self.fetchResCompany();
+      }).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.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.fetchPosOrder();
+      }).then(function(PosOrder) {
+        self.PosOrder = PosOrder;
+        return self.fetchDelivery();
+      }).then(function(Delivery) {
+        self.Delivery = Delivery;
+        return self.BuildTable();
+      });
+    },
+
+    /*=====================================================================
+        IR MODULE
+    =====================================================================*/
+    fecthIrModuleModule: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['name', 'id'];
+      var domain = [
+        ['state', '=', 'installed'],
+        ['name', 'in', self.modules]
+      ];
+      var IrModuleModule = new model.web.Model('ir.module.module');
+      IrModuleModule.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      })
+      return defer;
+    },
+
+    /*=====================================================================
+        Check type
+    =====================================================================*/
+    fecthCheckType: function() {
+      var self = this;
+      var modules = self.checkModel('point_of_sale');
+      if (modules.length == 0) {
+        self.$el.find('.type').css('display', 'none');
+      }
+    },
+
+    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()
+      });
+    },
+
+
+    /*=====================================================================
+        USER
+    =====================================================================*/
+    fetchResUser: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'name', 'store_id'];
+      var domain = [
+        ['active', '=', true]
+      ];
+      var ResUser = new model.web.Model('res.users');
+      ResUser.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+    /*====================================================================
+        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 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;
+    },
+
+    /*====================================================================
+        ACCOUNT INVOICE
+    ====================================================================*/
+
+
+    fetchAccountInvoice: function () {
+        var self = this;
+        var defer = $.Deferred();
+
+        var store = self.$el.find('#current-store').val();
+        var period = self.$el.find('#current-period').val();
+        var company = self.$el.find('#current-company').val();
+
+
+        if (store && store != 9999999) {
+          var journal_ids = _.map(_.filter(self.AccountJournal, function(item) {
+            return item.store_ids[0] == 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 (company && company != 9999999) {
+          domain.push(['company_id', '=', parseInt(company)]);
+        }
+
+
+        if (period && period != 9999999) {
+          domain.push(['period_id', '=', parseInt(period)]);
+        }
+
+        var field =['id', 'number', 'state','type','amount_total','user_id','company_id','period_id','date_invoice','journal_id', 'is_delivery','delivery_type'];
+        var AccountInvoice = new model.web.Model('account.invoice');
+        AccountInvoice.query(field).filter(domain).all().then(function (results) {
+          defer.resolve(results);
+        });
+        return defer;
+      },
+
+
+
+
+    fetchPosOrder: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var type = $('#current-type').val();
+      var modules = self.checkModel('point_of_sale');
+      if (type && modules.length > 0) {
+        if (type != 'sale') {
+          var store = self.$el.find('#current-store').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[0] == store;
+            }), function(map) {
+              return map.id;
+            });
+          } else {
+            var journal_ids = _.flatten(_.map(self.AccountJournal, function(item) {
+              return item.id;
+            }));
+          }
+          var domain = [
+            ['state', 'not in', ['draft', 'cancel']],
+            ['sale_journal', 'in', journal_ids],
+          ];
+          if (company && company != 9999999) {
+            domain.push(['company_id', '=', parseInt(company)]);
+          }
+          if (journal && journal != 9999999) {
+            domain.push(['sale_journal', '=', parseInt(journal)]);
+          }
+
+          if (date && date != 9999999) {
+            if (date == 'range') {
+              if (desde) {
+                var date = desde.split('/')
+                date = (date[2] + "-" + date[1] + "-" + date[0]);
+                domain.push(['date_order', '>=', date]);
+              }
+            }
+            if (date == 'today') {
+              var today = moment().format('YYYY-MM-DD 00:00:00');
+              domain.push(['date_order', '>=', today]);
+            }
+            if (date == 'yesterday') {
+              var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD 00:00:00');
+              domain.push(['date_order', '>=', yesterday]);
+            }
+            if (date == 'currentMonth') {
+              var currentMonth = moment().format('YYYY-MM');
+              domain.push(['date_order', 'like', currentMonth]);
+            }
+            if (date == 'lastMonth') {
+              var lastMonth = moment().add(-1, 'months').format('YYYY-MM');
+              domain.push(['date_order', 'like', lastMonth]);
+            }
+          }
+          var PosOrder = new model.web.Model('account.invoice');
+          return PosOrder.call('getPosOrder', [domain], {
+            context: new model.web.CompoundContext()
+          });
+        }
+      } else {
+        var PosOrder = [];
+        return PosOrder;
+      }
+    },
+
+    fetchDelivery: function() {
+      var self = this;
+      var defer = $.Deferred();
+      var fields = ['id', 'store_id', 'delivery_type', 'amount'];
+      var domain = [];
+      var Delivery = new model.web.Model('delivery.check');
+      Delivery.query(fields).filter(domain).all().then(function(results) {
+        defer.resolve(results);
+      });
+      return defer;
+    },
+
+
+
+
+    /*====================================================================
+        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 sucursales</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 sucursales</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>');
+        });
+      }
+    },
+
+
+    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;
+      })
+    },
+
+    getAccountInvoice: function(id) {
+      var self = this;
+      return _.filter(self.AccountInvoice, function(item) {
+        return item.user_id[0] === id;
+      })
+    },
+
+    getResUser: function(id) {
+      var self = this;
+      var store = self.$el.find('#current-store').val();
+      var content = self.ResUser;
+
+      if(store && store != 9999999){
+              content = _.flatten(_.filter(content,function (item) {
+                  return item.store_id[0] == store;
+              }));
+          }
+          return content;
+    },
+
+    getDelivery: function(type, store) {
+      var self = this;
+      return _.map(_.filter(self.Delivery, function(item) {
+        return item.delivery_type == type && item.store_id[0] == store;
+      }), function(map){
+        return map.amount;
+      })
+    },
+
+
+
+
+    /*====================================================================
+        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();
+      };
+      /*
+      ==========================================
+          RECORRER PRODUCTOS
+      ==========================================
+      */
+      var ResUser = self.getResUser();
+      _.each(ResUser, function(i) {
+
+
+        var suma_local = 0;
+        var suma_envio = 0;
+        var local_amount = 0;
+        var envio_amount = 0;
+
+        var local_delivery_amount = self.getDelivery("local", i.store_id[0]);
+        var envio_delivery_amount = self.getDelivery("envio", i.store_id[0]);
+
+        var AccountInvoice = self.getAccountInvoice(i.id);
+        _.each(AccountInvoice, function(item){
+
+          if (item.is_delivery == true && item.delivery_type == "local"){
+            suma_local = suma_local + 1;
+          }
+
+          if (item.is_delivery == true && item.delivery_type == "envio"){
+            suma_envio = suma_envio + 1;
+          }
+        })
+
+        local_amount = suma_local * local_delivery_amount[0];
+        envio_amount = suma_envio * envio_delivery_amount[0];
+
+        console.log(local_amount);
+
+        data.push({
+          user : i.name,
+          suma_local : suma_local,
+          suma_envio : suma_envio,
+
+          local_amount : accounting.formatMoney(local_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+          envio_amount : accounting.formatMoney(envio_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+
+          local_amount_no_format : self.valorNull(local_amount),
+          envio_amount_no_format : self.valorNull(envio_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');
+
+
+      // impresion por categorias
+
+      if (action === 'pdf') {
+        var suma_local = localFormatter(row);
+        var suma_envio = envioFormatter(row);
+        var local_amount = localAmountFormatter(row);
+        var envio_amount = envioAmountFormatter(row);
+
+        row.push({
+          user: 'Totales',
+          suma_local: suma_local,
+          suma_envio: suma_envio,
+          local_amount: local_amount,
+          envio_amount: envio_amount,
+        })
+        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 = 'Comisión por delivery.';
+        var pdf_type = '';
+        var pdf_name = 'comision_por_delivery_';
+        var pdf_columnStyles = {
+          user: {
+            halign: 'left'
+          },
+          suma_local: {
+            columnWidth: 30,
+            halign: 'center'
+          },
+          suma_envio: {
+            columnWidth: 30,
+            halign: 'center'
+          },
+          local_amount: {
+            columnWidth: 30,
+            halign: 'center'
+          },
+          envio_amount: {
+            columnWidth: 30,
+            halign: 'center'
+          },
+        };
+        /*
+        ============================================================
+            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 period = self.$el.find('#current-period').val();
+
+      var filter = [];
+      if (company && company != 9999999) {
+        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 (period && period != 9999999) {
+        var AccountPeriod = _.filter(self.AccountPeriod, function(item) {
+          return item.id == period;
+        });
+        filter.push({
+          title: 'Periodo',
+          value: AccountPeriod[0].name,
+        });
+      };
+
+      return filter;
+    },
+  });
+}

+ 151 - 0
static/src/reports/report_delivery_baco.xml

@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportDeliveryWidget">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Comisión por delivery</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 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </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 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-classes="table table-condensed  table-no-bordered"
+                        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 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="user" data-align="left" data-footer-formatter="Totales">Vendedor</th>
+                                <th data-field="suma_local" data-align="center" data-footer-formatter="localFormatter">Cantidad Delivery Local</th>
+                                <th data-field="local_amount" data-align="center" data-footer-formatter="localAmountFormatter">Comisión Delivery Local</th>
+                                <th data-field="suma_envio" data-align="center" data-footer-formatter="envioFormatter">Cantidad Envío al interior</th>
+                                <th data-field="envio_amount" data-align="center" data-footer-formatter="envioAmountFormatter">Comisión Envío al interior</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+                <!--
+                    TOTAL CANTIDAD LOCAL
+                -->
+                function localFormatter(rowsTable) {
+                  var amount = 0;
+
+                  amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.suma_local);
+                    }), function(memo, num){
+                    return memo + num; },0)
+
+                    return amount;
+                }
+                <!--
+                    TOTAL MONTO LOCAL
+                -->
+                function localAmountFormatter(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.local_amount_no_format);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+                <!--
+                    TOTAL CANTIDAD ENVIO
+                -->
+                function envioFormatter(rowsTable) {
+                var amount = 0;
+
+                amount =  _.reduce(_.map(rowsTable,function(item){
+                    return (item.suma_envio);
+                }), function(memo, num){
+                return memo + num; },0)
+
+                return amount;
+                }
+                <!--
+                    TOTAL MONTO ENVIO
+                -->
+                function envioAmountFormatter(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.envio_amount_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>

+ 2 - 1
templates.xml

@@ -11,8 +11,9 @@
 
         <!-- ================================= BACO ========================================= -->
 
-        <!--============================= Ranking de productos ==============================-->
+
         <script type="text/javascript" src="/eiru_reports_baco/static/src/js/reports/report_product_ranking_baco.js"/>
+        <script type="text/javascript" src="/eiru_reports_baco/static/src/js/reports/report_delivery_baco.js"/>
 
       </xpath>
     </template>

+ 6 - 0
views/actions.xml

@@ -6,5 +6,11 @@
 			<field name="name">Ranking de productos por categoría</field>
 			<field name="tag">eiru_reports_baco.product_ranking_baco_action</field>
 		</record>
+
+
+		<record id="delivery_action" model="ir.actions.client">
+			<field name="name">Delivery por vendedor</field>
+			<field name="tag">eiru_reports_baco.delivery_action</field>
+		</record>
 	</data>
 </openerp>

+ 2 - 0
views/menus.xml

@@ -7,6 +7,8 @@
     <!-- sub menu -->
 
     <menuitem id="product_ranking_baco_menu" parent="baco_parent_menu" name="Ranking de productos por categoría" action="product_ranking_baco_action" sequence="1"/>
+    <menuitem id="delivery_menu" parent="baco_parent_menu" name="Delivery por vendedor" action="delivery_action" sequence="2"/>
+
 
   </data>
 </openerp>