Parcourir la source

[ADD - FIX] Agregado el concepto de multi-divisa y multi-sucursal al los widgets de banco y caja. Eliminado dependencia de loading.js. eliminados widgets innecesarios

Rodney Elpidio Enciso Arias il y a 6 ans
Parent
commit
c1edac31fd
50 fichiers modifiés avec 1489 ajouts et 3413 suppressions
  1. 2 1
      __openerp__.py
  2. 50 42
      data/charts_data.xml
  3. 5 2
      models/chart_config.py
  4. BIN
      models/chart_config.pyc
  5. 53 0
      static/src/css/circliful.css
  6. 2 3
      static/src/css/dashboard.css
  7. 0 1
      static/src/css/loading-bar.css
  8. 0 0
      static/src/js/charts/chart_ingreso_egreso.js
  9. 54 18
      static/src/js/charts/chart_ranking_customer.js
  10. 71 31
      static/src/js/charts/chart_ranking_product.js
  11. 52 17
      static/src/js/charts/chart_ranking_salesman.js
  12. 460 0
      static/src/js/charts/chart_sale_by_store.js
  13. 11 99
      static/src/js/dashboard.js
  14. 18 15
      static/src/js/main.js
  15. 0 279
      static/src/js/widgets/chart_invoice.js
  16. 0 323
      static/src/js/widgets/chart_pos_order.js
  17. 0 276
      static/src/js/widgets/chart_purchase_expense.js
  18. 0 315
      static/src/js/widgets/chart_sale_by_store.js
  19. 0 276
      static/src/js/widgets/chart_sale_order_customer.js
  20. 0 235
      static/src/js/widgets/chart_sale_order_product.js
  21. 0 256
      static/src/js/widgets/chart_sale_order_salesman.js
  22. 1 1
      static/src/js/widgets/widget_account_receivable.js
  23. 1 1
      static/src/js/widgets/widget_account_to_pay.js
  24. 64 24
      static/src/js/widgets/widget_balance.js
  25. 0 406
      static/src/js/widgets/widget_balance_sale.js
  26. 17 30
      static/src/js/widgets/widget_bank.js
  27. 17 29
      static/src/js/widgets/widget_cash.js
  28. 27 27
      static/src/js/widgets/widget_expense.js
  29. 17 9
      static/src/js/widgets/widget_purchase.js
  30. 80 43
      static/src/js/widgets/widget_sale.js
  31. 0 449
      static/src/js/widgets/widget_sale_order.js
  32. 437 0
      static/src/lib/circliful.js
  33. 0 0
      static/src/xml/charts/chart_ingreso_egreso.xml
  34. 1 1
      static/src/xml/charts/chart_ranking_customer.xml
  35. 1 1
      static/src/xml/charts/chart_ranking_product.xml
  36. 1 1
      static/src/xml/charts/chart_ranking_salesman.xml
  37. 0 0
      static/src/xml/charts/chart_sale_by_store.xml
  38. 0 39
      static/src/xml/widgets/chart_invoice.xml
  39. 0 40
      static/src/xml/widgets/chart_pos_order.xml
  40. 0 40
      static/src/xml/widgets/chart_purchase_expense.xml
  41. 0 14
      static/src/xml/widgets/chart_sale_order_customer.xml
  42. 0 13
      static/src/xml/widgets/chart_sale_order_product.xml
  43. 0 14
      static/src/xml/widgets/chart_sale_order_salesman.xml
  44. 1 4
      static/src/xml/widgets/eiru_dashboard_modal.xml
  45. 2 4
      static/src/xml/widgets/widget_balance.xml
  46. 2 4
      static/src/xml/widgets/widget_expense.xml
  47. 4 1
      static/src/xml/widgets/widget_modal.xml
  48. 2 4
      static/src/xml/widgets/widget_purchase.xml
  49. 5 7
      static/src/xml/widgets/widget_sale.xml
  50. 31 18
      templates.xml

+ 2 - 1
__openerp__.py

@@ -26,6 +26,7 @@
     ],
     'qweb': [
         'static/src/xml/*.xml',
-        'static/src/xml/widgets/*.xml'
+        'static/src/xml/widgets/*.xml',
+        'static/src/xml/charts/*.xml',
     ]
 }

+ 50 - 42
data/charts_data.xml

@@ -2,70 +2,78 @@
 <openerp>
     <data>
 
-        <!-- data -->
+        <!--===========  
+            CHARTS
+        ============-->
+
+        <!-- Ranking de clientes -->
+        <record model="chart.list" id="chart_RankingCustomer">
+            <field name="name">ChartRankingCustomer</field>
+        </record>
         
-        <record model="chart.list" id="chart_ChartInvoice">
-            <field name="name">ChartInvoice</field>
+        <!-- Ranking de productos -->
+        <record model="chart.list" id="chart_RankingProduct">
+            <field name="name">ChartRankingProduct</field>
         </record>
-        <record model="chart.list" id="chart_ChartPosOrder">
-            <field name="name">ChartPosOrder</field>
+        
+        <!-- Ranking de vendedores -->
+        <record model="chart.list" id="chart_RankingSalesman">
+            <field name="name">ChartRankingSalesman</field>
         </record>
-        <record model="chart.list" id="chart_ChartPosOrderCustomer">
-            <field name="name">ChartPosOrderCustomer</field>
+        
+        <!-- flujo de caja -->
+        <record model="chart.list" id="chart_ChartIngresoEgreso">
+            <field name="name">ChartIngresoEgreso</field>
         </record>
-        <record model="chart.list" id="chart_ChartPosOrderProduct">
-            <field name="name">ChartPosOrderProduct</field>
+        
+        <!-- ventas por sucursal -->
+        <record model="chart.list" id="chart_ChartSaleByStore">
+            <field name="name">ChartSaleByStore</field>
         </record>
-        <record model="chart.list" id="chart_ChartPosOrderSalesman">
-            <field name="name">ChartPosOrderSalesman</field>
+
+        <!--===========  
+            WIDGET
+        ============-->
+        
+        <!-- ventas -->
+        <record model="chart.list" id="widget_sale">
+            <field name="name">WidgetSale</field>
         </record>
-        <record model="chart.list" id="chart_ChartPurchaseExpense">
-            <field name="name">ChartPurchaseExpense</field>
+
+        <!-- Compras -->
+        <record model="chart.list" id="widget_WidgetPurchase">
+            <field name="name">WidgetPurchase</field>
         </record>
-        <record model="chart.list" id="widget_WidgetPosOrder">
-            <field name="name">WidgetPosOrder</field>
+        
+        <!-- Gastos -->
+         <record model="chart.list" id="widget_WidgetExpense">
+            <field name="name">WidgetExpense</field>
         </record>
+
+        <!-- Balance -->
         <record model="chart.list" id="widget_WidgetBalance">
             <field name="name">WidgetBalance</field>
         </record>
-        <record model="chart.list" id="widget_WidgetExpense">
-            <field name="name">WidgetExpense</field>
-        </record>
-        <record model="chart.list" id="widget_WidgetPurchase">
-            <field name="name">WidgetPurchase</field>
-        </record>
+       
+        <!-- Dinero en caja -->
         <record model="chart.list" id="widget_WidgetCash">
             <field name="name">WidgetCash</field>
         </record>
+
+        <!-- Dinero en banco -->
         <record model="chart.list" id="widget_WidgetBank">
             <field name="name">WidgetBank</field>
         </record>
-        <record model="chart.list" id="chart_ChartIngresoEgreso">
-            <field name="name">ChartIngresoEgreso</field>
-        </record>
+
+        <!-- cuentas a cobrar -->
         <record model="chart.list" id="chart_WidgetAccountReceivable">
             <field name="name">WidgetAccountReceivable</field>
         </record>
+
+        <!-- cuentas a pagar -->
         <record model="chart.list" id="chart_WidgetAccountToPay">
             <field name="name">WidgetAccountToPay</field>
         </record>
-        <record model="chart.list" id="chart_ChartSaleByStore">
-            <field name="name">ChartSaleByStore</field>
-        </record>
-        <record model="chart.list" id="Widget_WidgetSaleOrder">
-            <field name="name">WidgetSaleOrder</field>
-        </record>
-        <record model="chart.list" id="Widget_WidgetBalanceSale">
-            <field name="name">WidgetBalanceSale</field>
-        </record>
-        <record model="chart.list" id="chart_ChartSaleOrderCustomer">
-            <field name="name">ChartSaleOrderCustomer</field>
-        </record>
-        <record model="chart.list" id="chart_ChartSaleOrderProduct">
-            <field name="name">ChartSaleOrderProduct</field>
-        </record>
-        <record model="chart.list" id="chart_ChartSaleOrderSalesman">
-            <field name="name">ChartSaleOrderSalesman</field>
-        </record>
+        
     </data>
 </openerp>

+ 5 - 2
models/chart_config.py

@@ -1,6 +1,10 @@
 # -*- encoding: utf-8 -*-
 from openerp import models, fields, api
+from datetime import datetime
+from pytz import timezone
 
+DATE_FORMAT = '%Y-%m-01 00:00:00'
+# import web_pdb; web_pdb.set_trace()
 
 class ChartList(models.Model):
     _name = 'chart.list'
@@ -17,5 +21,4 @@ class ResUsers(models.Model):
 
 	@api.model
 	def get_user(self):
-		return self.env.user.id
-
+		return self.env.user.id

BIN
models/chart_config.pyc


+ 53 - 0
static/src/css/circliful.css

@@ -0,0 +1,53 @@
+.circliful .outer {
+    fill: transparent;
+    stroke: #333;
+    stroke-width: 19.8;
+    stroke-dasharray: 534;
+    transition: stroke-dashoffset 1s;
+    -webkit-animation-play-state: running;
+    /* firefox bug fix - won't rotate at 90deg angles */
+    -moz-transform: rotate(-89deg) translateX(-190px);
+}
+
+/* full circle 25 empty 534 */
+.circliful .inner {
+    fill: transparent;
+    stroke: orange;
+    stroke-width: 20;
+    stroke-dasharray: 534;
+    transition: stroke-dashoffset 1s;
+    -webkit-animation-play-state: running;
+    /* firefox bug fix - won't rotate at 90deg angles */
+    -moz-transform: rotate(-89deg) translateX(-190px);
+    stroke-dashoffset: 0;
+}
+
+.circliful {
+    overflow: visible !important;
+
+}
+
+.svg-container {
+    width: 100%;
+    margin: 0 auto;
+    overflow: visible;
+    position: relative;
+}
+
+svg .icon {
+    font-family: FontAwesome;
+}
+
+.legend-line {
+    white-space: nowrap;
+}
+
+.color-box {
+    width: 15px;
+    height: 15px;
+    border-radius: 2px;
+    display: inline-block;
+    float: left;
+    padding-top: 3px;
+    margin: 2px 5px 0 0;
+}

+ 2 - 3
static/src/css/dashboard.css

@@ -11,10 +11,8 @@
     display: flex;
     flex-direction: column;
     justify-content: center;
-    /*padding: 1em;*/
     color:#1e88e5;
     border-bottom: 3px solid #1e88e5;
-    /*background-color: #fff;*/
     overflow-y: hidden !important;
 }
 
@@ -23,9 +21,10 @@
 .grid-stack-item-content.reporting-dashboard.green {
     color: #43a047;
     border-bottom: 3px solid #43a047;
+    /*vertical-align: middle;*/
     /*border: 1px solid #43a047;*/
     /*border-radius: 6px;*/
-    /*background: #43a047*/
+    /*background: #f5f5f5*/
 }
 .grid-stack-item-content.reporting-dashboard.green > .widget-content > .row > .col-xs-12.col-md-12.col-lg-8.text-right > a {
     color: #43a047;

+ 0 - 1
static/src/css/loading-bar.css

@@ -1 +0,0 @@
-.ldBar{position:relative;}.ldBar.label-center > .ldBar-label{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);text-shadow:0 0 3px #fff}.ldBar-label:after{content:"%";display:inline}.ldBar.no-percent .ldBar-label:after{content:""}

+ 0 - 0
static/src/js/widgets/chart_ingreso_egreso.js → static/src/js/charts/chart_ingreso_egreso.js


+ 54 - 18
static/src/js/widgets/chart_pos_order_customer.js → static/src/js/charts/chart_ranking_customer.js

@@ -1,30 +1,44 @@
-function chart_pos_order_customer (widget) {
+function chart_ranking_customer (widget) {
     "use strict";
 
     var model = openerp;
 
-    widget.ChartPosOrderCustomerWidget = widget.Base.extend({
-        template: 'ChartPosOrderCustomer',
+    widget.ChartRankingCustomer = widget.Base.extend({
+        template: 'ChartRankingCustomer',
+        modules: ['point_of_sale'],
         data: [],
 
         events: {
             
         },
+
         init: function (parent) {
             this._super(parent, {
                 width: 6,
                 height: 4
             });
         },
+
         start: function () {
             var self = this;
             self.fetchInitial();
         },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
         fetchInitial:function() {
             var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -48,6 +62,22 @@ function chart_pos_order_customer (widget) {
             });
         },
 
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
         /* 
             USER
         */
@@ -81,17 +111,23 @@ function chart_pos_order_customer (widget) {
         fetchPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var date = moment().add(-1, 'month').format('YYYY-MM-23 00:00:00');
-            var fields = ['id','date_order','partner_id','amount_total'];
-            var domain = [['state', 'in', ['paid','done','invoiced']], ['partner_id', '!=', false],['date_order', '>=', date],['sale_journal','in',journal_ids]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+                var date = moment().add(-1, 'month').format('YYYY-MM-23 00:00:00');
+                var fields = ['id','date_order','partner_id','amount_total'];
+                var domain = [['state', 'in', ['paid','done','invoiced']], ['partner_id', '!=', false],['date_order', '>=', date],['sale_journal','in',journal_ids]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function (results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
         },        
 
         fetchAccountInvoice: function() {
@@ -207,7 +243,7 @@ function chart_pos_order_customer (widget) {
                     ranking.push({
                         id: self.ResPartner[i].id,
                         name: self.ResPartner[i].name,
-                        countPosOrder: accounting.formatNumber(amount,0,"",","),
+                        countPosOrder: amount,
                     });    
                 }
             }

+ 71 - 31
static/src/js/widgets/chart_pos_order_product.js → static/src/js/charts/chart_ranking_product.js

@@ -1,30 +1,44 @@
-function chart_pos_order_product (widget) {
+function chart_ranking_product (widget) {
     "use strict";
 
     var model = openerp;
 
-    widget.ChartPosOrderProductWidget = widget.Base.extend({
-        template: 'ChartPosOrderProduct',
+    widget.ChartRankingProduct = widget.Base.extend({
+        template: 'ChartRankingProduct',
+        modules: ['point_of_sale'],
         data: [],
 
         events: {
             
         },
+
         init: function (parent) {
             this._super(parent, {
                 width: 6,
                 height: 4
             });
         },
+
         start: function () {
             var self = this;
             self.fetchInitial();
         },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
         fetchInitial: function() {
             var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -48,6 +62,22 @@ function chart_pos_order_product (widget) {
             });
         },
 
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
         /* 
             USER
         */
@@ -81,34 +111,44 @@ function chart_pos_order_product (widget) {
         fecthPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var date = moment().format('YYYY-MM-01 00:00:00');
-            var fields = ['id', 'lines', 'date_order'];
-            var domain = [['state', 'in', ['paid','done','invoiced']],['sale_journal','in',journal_ids],['date_order','>=',date]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+                var date = moment().format('YYYY-MM-01 00:00:00');
+                var fields = ['id', 'lines', 'date_order'];
+                var domain = [['state', 'in', ['paid','done','invoiced']],['sale_journal','in',journal_ids],['date_order','>=',date]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function (results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
         },
 
         fecthPosOrderLine: function() {
             var self = this;
             var defer = $.Deferred();
-            var lines = _.flatten(_.map(self.PosOrder, function (item) {
-                return item.lines;
-            }));
-            var fields = ['id', 'product_id', 'qty','create_date'];
-            var domain = [['id','in', lines]];
-            var PosOrderLine = new model.web.Model('pos.order.line');
-            PosOrderLine.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var lines = _.flatten(_.map(self.PosOrder, function (item) {
+                    return item.lines;
+                }));
+                var fields = ['id', 'product_id', 'qty','create_date'];
+                var domain = [['id','in', lines]];
+                var PosOrderLine = new model.web.Model('pos.order.line');
+                PosOrderLine.query(fields).filter(domain).all().then(function (results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrderLine = [];
+                return PosOrderLine;
+            }
         },
 
         fetchAccountInvoice: function() {
@@ -119,7 +159,7 @@ function chart_pos_order_product (widget) {
             }));
             var desde = moment().format('YYYY-MM-01');
             var hasta = moment().add(1,'months').format('YYYY-MM-01');
-            var fields = ['id', 'invoice_line', 'date_order'];
+            var fields = ['id', 'invoice_line', 'date_invoice'];
             var domain = [['date_invoice', '>=', desde],['date_invoice', '<', hasta],['state', 'in', ['open','paid']],['journal_id','in',journal_ids],['type','=','out_invoice']];
             var AccountInvoice = new model.web.Model('account.invoice');
             AccountInvoice.query(fields).filter(domain).all().then(function (results) {
@@ -203,7 +243,7 @@ function chart_pos_order_product (widget) {
                     ranking.push({
                         id: self.ProductProduct[i].id,
                         product: self.ProductProduct[i].name_template + ' ' + attribute,
-                        qty: accounting.formatNumber(qty,0,"",","),
+                        qty: qty,
                     });
                 }
             }

+ 52 - 17
static/src/js/widgets/chart_pos_order_salesman.js → static/src/js/charts/chart_ranking_salesman.js

@@ -1,10 +1,11 @@
-function chart_pos_order_salesman (widget) {
+function chart_ranking_salesman (widget) {
     "use strict";
 
     var model = openerp;
 
-    widget.ChartPosOrderSalesmanWidget = widget.Base.extend({
-        template: 'ChartPosOrderSalesman',
+    widget.ChartRankingSalesman = widget.Base.extend({
+        template: 'ChartRankingSalesman',
+        modules: ['point_of_sale'],
         events: {
             
         },
@@ -15,15 +16,27 @@ function chart_pos_order_salesman (widget) {
                 height: 4
             });
         },
+
         start: function () {
             var self = this;
             self.fetchInitial();
         },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
         fetchInitial:function() {
             var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -34,7 +47,7 @@ function chart_pos_order_salesman (widget) {
                 return self.fetchAccountInvoice();
             }).then(function (AccountInvoice) {
                 self.AccountInvoice = AccountInvoice;
-                return self.fetchResCompany(self.CurrentUser);
+                return self.fetchResCompany();
             }).then(function(ResCompany) {
                 self.ResCompany = ResCompany;
                 return self.fetchResCurrency();
@@ -44,6 +57,22 @@ function chart_pos_order_salesman (widget) {
             });
         },
 
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
         /* 
             USER
         */
@@ -80,14 +109,20 @@ function chart_pos_order_salesman (widget) {
         fecthPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
-            var date = moment().add(-1, 'month').format('YYYY-MM-23 00:00:00');
-            var fields = ['id','date_order','partner_id','amount_total','user_id'];
-            var domain = [['state', 'in', ['paid','done','invoiced']],['date_order','>=',date]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var date = moment().add(-1, 'month').format('YYYY-MM-23 00:00:00');
+                var fields = ['id','date_order','partner_id','amount_total','user_id'];
+                var domain = [['state', 'in', ['paid','done','invoiced']],['date_order','>=',date]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function (results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
         },
 
         fetchAccountInvoice: function() {
@@ -98,7 +133,7 @@ function chart_pos_order_salesman (widget) {
             }));
             var desde = moment().format('YYYY-MM-01');
             var hasta = moment().add(1,'months').format('YYYY-MM-01');
-            var fields = ['id', 'invoice_line', 'date_order','user_id','amount_total','currency_id'];
+            var fields = ['id', 'invoice_line', 'date_invoice','user_id','amount_total','currency_id'];
             var domain = [['date_invoice', '>=', desde], ['date_invoice', '<', hasta],['state', 'in', ['open','paid']],['journal_id','in',journal_ids],['type','=','out_invoice']];
             var AccountInvoice = new model.web.Model('account.invoice');
             AccountInvoice.query(fields).filter(domain).all().then(function (results) {
@@ -188,7 +223,7 @@ function chart_pos_order_salesman (widget) {
                     ranking.push({
                         id: self.ResUser[i].id,
                         name: self.ResUser[i].name,
-                        amount: accounting.formatNumber(amount,0,"",","),
+                        amount: amount,
                     });
                 }
             }

+ 460 - 0
static/src/js/charts/chart_sale_by_store.js

@@ -0,0 +1,460 @@
+function chart_sale_by_store (widget) {
+    "use strict";
+
+    var model = openerp;
+
+    widget.ChartSaleByStoreWidget = widget.Base.extend({
+        template: 'ChartSaleByStore',
+        modules: ['point_of_sale'],
+        data: [],
+        events: {
+            'click .month': 'showMonth',
+            'click .week': 'showWeek',
+            'click .days': 'showToday',
+        },
+
+        init: function (parent) {
+            this._super(parent, {
+                width: 6,
+                height: 4
+            });
+        },
+
+        start: function () {
+            var self = this;
+            self.fetchInitial();
+        },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
+        fetchInitial:function() {
+            var self = this;
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchAccountJournal();
+            }).then(function (AccountJournal) {
+                self.AccountJournal = AccountJournal;
+                return self.fetchPosOrder();
+            }).then(function (PosOrder) {
+                self.PosOrder = PosOrder;
+                return self.fetchAccountInvoice();
+            }).then(function (AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchResStore();
+            }).then(function (ResStore) {
+                self.ResStore = ResStore;
+                return self.fetchResCompany();
+            }).then(function(ResCompany) {
+                self.ResCompany = ResCompany;
+                return self.fetchResCurrency();
+            }).then(function(ResCurrency) {
+                self.ResCurrency = ResCurrency;
+                return self.showMonth();
+            });
+        },
+
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
+        fetchAccountJournal: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id', 'name', 'store_ids'];
+            var domain = [['type','=','sale']];
+            var AccountJournal = new model.web.Model('account.journal');
+            AccountJournal.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+        
+        fetchPosOrder: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var date = moment().add(-1, 'month').format('YYYY-MM-20 00:00:00');
+                var fields = ['id','date_order','amount_total','sale_journal'];
+                var domain = [['state','not in',['draft','cancel']],['date_order','>',date]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function (results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
+        },
+
+        fetchAccountInvoice: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var desde = moment().format('YYYY-MM-01');
+            var hasta = moment().add(1,'months').format('YYYY-MM-01');
+            var fields = ['id', 'name', 'date_invoice', 'amount_total','journal_id','currency_id'];
+            var domain = [['date_invoice','>=',desde], ['date_invoice','<',hasta],['state', 'not in', ['draft','cancel']],['type','=','out_invoice']];
+            var AccountInvoice = new model.web.Model('account.invoice');
+            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','journal_ids'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(fields).filter().all().then(function(results) {
+                defer.resolve(results);
+            });
+
+            return defer;
+        },
+
+        fetchResCompany: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name', 'currency_id'];
+            var domain = [['id', '=', self.session.company_id]];
+            var ResCompany = new model.web.Model('res.company');
+            ResCompany.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        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;
+        },
+
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+        /*=========
+        POS ORDER
+        =========*/
+
+        getMonthPosOrder:function(id) {
+            var self = this;
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                })); 
+                return _.flatten(_.filter(self.PosOrder,function (inv) {
+                    var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
+                    return moment(utc._d).format('YYYY-MM') === moment().format('YYYY-MM') & _.contains(journal_ids, inv.sale_journal[0]);
+                }));
+            }
+        },
+
+        getWeekPosOrder:function(id) {
+            var self = this;
+            var week = moment().week();
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                })); 
+                return _.flatten(_.filter(self.PosOrder,function (inv) {
+                    var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
+                    utc = moment(utc._d).format('YYYY-MM-DD');
+                    return moment(utc).week() === week & _.contains(journal_ids, inv.sale_journal[0]);
+                }));
+            }
+        },
+
+        getTodayPosOrder:function(id) {
+            var self = this;
+            var today = moment().format('YYYY-MM-DD');
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                })); 
+                return _.flatten(_.filter(self.PosOrder,function (inv) {
+                    var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
+                    return moment(utc._d).format('YYYY-MM-DD') === today & _.contains(journal_ids, inv.sale_journal[0]);
+                }));
+            }
+        },
+
+        /*===============
+        ACCOUNT INVOICE
+        ===============*/
+
+        getMonthAccountInvoice:function(id) {
+            var self = this;
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                })); 
+                return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                    return moment(inv.date_invoice).format('YYYY-MM') === moment().format('YYYY-MM') & _.contains(journal_ids, inv.journal_id[0]);
+                }));   
+            }
+            
+        },
+
+        getWeekAccountInvoice:function(id) {
+            var self = this;
+            var week = moment().week();
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                }));
+                return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                    return moment(inv.date_invoice).week() === week & _.contains(journal_ids, inv.journal_id[0]);
+                }));
+            }
+        },  
+
+        getTodayAccountInvoice:function(id) {
+            var self = this;
+            var today = moment().format('YYYY-MM-DD');
+            var journals  = _.filter(self.AccountJournal,function (inv) {
+                return inv.store_ids[0] === id;
+            });
+            if(journals.length > 0){
+                var journal_ids = _.flatten(_.map(journals, function (item) {
+                    return item.id;
+                }));
+                return _.flatten(_.filter(self.AccountInvoice,function (inv) {
+                    return moment(inv.date_invoice).format('YYYY-MM-DD') === today & _.contains(journal_ids, inv.journal_id[0])
+                }));
+            }
+        },
+  
+        showMonth: function() {
+            var self = this;
+            var order;
+            var invoice;
+            var title = [];
+            var data = [];
+            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            _.each(self.ResStore, function(item){
+                var array = [];
+                title.push(item.name);
+                order = self.getMonthPosOrder(item.id);
+                invoice = self.getMonthAccountInvoice(item.id);
+                var order_total = _.reduce(_.map(order,function(item) {
+                    return item.amount_total;
+                }),function(memo, num) {
+                    return memo + num;
+                },0);
+                _.each(invoice, function (item) {
+                    var currency = self.getResCurrency(item.currency_id[0]).shift();
+                    array.push({
+                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
+                    })
+                });
+                var invoice_total = 0;
+                if(array.length > 0){
+                    invoice_total = _.reduce(_.map(array, function (map) {
+                        return map.amount;
+                    }), function (memo, num) {
+                        return memo + num;
+                    });
+                }
+                var total = order_total + invoice_total;
+                data.push(total); 
+            });
+            self.fetchChart(data,title);
+        },
+
+        showWeek: function () {
+            var self = this;
+            var order;
+            var invoice;
+            var title = [];
+            var data = [];
+            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();            
+            _.each(self.ResStore, function(item){
+                var array = [];
+                title.push(item.name);
+                order = self.getWeekPosOrder(item.id);
+                invoice = self.getWeekAccountInvoice(item.id);
+                var order_total = _.reduce(_.map(order,function(item) {
+                    return item.amount_total;
+                }),function(memo, num) {
+                    return memo + num;
+                },0);
+                _.each(invoice, function (item) {
+                    var currency = self.getResCurrency(item.currency_id[0]).shift();
+                    array.push({
+                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
+                    })
+                });
+                var invoice_total = 0;
+                if(array.length > 0){
+                    invoice_total = _.reduce(_.map(array, function (map) {
+                        return map.amount;
+                    }), function (memo, num) {
+                        return memo + num;
+                    });
+                }
+                var total = order_total + invoice_total;
+                data.push(total); 
+            });
+            self.fetchChart(data,title);
+        },
+
+        showToday: function (){
+            var self = this;
+            var order;
+            var invoice;
+            var title = [];
+            var data = []; 
+            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();           
+            _.each(self.ResStore, function(item){
+                var array = []; 
+                title.push(item.name);
+                order = self.getTodayPosOrder(item.id);
+                invoice = self.getTodayAccountInvoice(item.id);
+                var order_total = _.reduce(_.map(order,function(item) {
+                    return item.amount_total;
+                }),function(memo, num) {
+                    return memo + num;
+                },0);
+                _.each(invoice, function (item) {
+                    var currency = self.getResCurrency(item.currency_id[0]).shift();
+                    array.push({
+                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
+                    })
+                });
+                var invoice_total = 0;
+                if(array.length > 0){
+                    invoice_total = _.reduce(_.map(array, function (map) {
+                    return map.amount;
+                    }), function (memo, num) {
+                        return memo + num;
+                    }); 
+                }
+                
+                var total = order_total + invoice_total;
+                data.push(total); 
+            });
+            self.fetchChart(data,title);
+        },
+
+        fetchChart: function (data,title) {
+            var self = this;
+            var label = title;
+            var body = data;
+
+            Chart.scaleService.updateScaleDefaults('linear', {
+              ticks: {
+                callback: function(tick) {
+                    return tick.toLocaleString('de-DE');
+                }
+              }
+            });
+
+            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
+                var dataset = data.datasets[tooltipItem.datasetIndex];
+                var datasetLabel = dataset.label || '';
+                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
+            };
+
+            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
+                type: 'horizontalBar',
+                data: {
+                    labels: label,
+                    datasets: [
+                        {
+                            label: false,
+                            data: body,
+                            backgroundColor: '#bbdefb',
+                            borderColor: '#0288d1',
+                            borderWidth: 1,
+                            fill: true,
+                            datalabels : {
+                                align   : 'end',
+                                anchor : 'end',
+                                display: true,
+                                backgroundColor: function(context) {
+                                    return context.dataset.backgroundColor;
+                                },
+                                borderRadius: 4,
+                                color: '#001f3f',
+                                font: {
+                                    weight: 'bold'
+                                }
+                            }
+                        }
+                    ]
+                },
+                options: {
+                    responsive: true,
+                    title: {
+                        display: false,
+                    },
+                    hover: {
+                        mode: 'nearest',
+                        intersect: true
+                    },
+                    legend: {
+                       display: false,
+                    },
+                    layout: {
+                        padding: {
+                            top: 0,
+                            bottom: 45,
+                            left : 0,
+                            rigth: 0,
+                        }
+                    },
+                    events: ['click'],
+                }
+            });
+        },
+
+    });
+}

+ 11 - 99
static/src/js/dashboard.js

@@ -34,24 +34,13 @@ function dashboard_reporting_widget (instance, widget) {
                         
                         // *************************** Ventas
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'WidgetPosOrder';
+                            return inv.name == 'WidgetSale';
                         }));
                         if(chart.length > 0){
-                            var wWidgetPosOrder = new widgets.WidgetPosOrderWidget(self);
-                            wWidgetPosOrder.renderElement();
-                            wWidgetPosOrder.start();
-                            self.grid.addWidget(wWidgetPosOrder.$el, 0, 0, wWidgetPosOrder.size.width,  wWidgetPosOrder.size.height, true);
-                        }
-
-                        // *************************** Ventas - [SALE]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'WidgetSaleOrder';
-                        }));
-                        if(chart.length > 0){
-                            var wWidgetSaleOrder = new widgets.WidgetSaleOrderWidget(self);
-                            wWidgetSaleOrder.renderElement();
-                            wWidgetSaleOrder.start();
-                            self.grid.addWidget(wWidgetSaleOrder.$el, 0, 0, wWidgetSaleOrder.size.width,  wWidgetSaleOrder.size.height, true);
+                            var wWidgetSale = new widgets.WidgetSale(self);
+                            wWidgetSale.renderElement();
+                            wWidgetSale.start();
+                            self.grid.addWidget(wWidgetSale.$el, 0, 0, wWidgetSale.size.width,  wWidgetSale.size.height, true);
                         }
 
                         // *************************** Compras
@@ -87,17 +76,6 @@ function dashboard_reporting_widget (instance, widget) {
                             self.grid.addWidget(wWidgetBalance.$el, 0, 0, wWidgetBalance.size.width,  wWidgetBalance.size.height, true);
                         }
 
-                        // *************************** balance - [SALE]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'WidgetBalanceSale';
-                        }));
-                        if(chart.length > 0){
-                            var wWidgetBalanceSale = new widgets.WidgetBalanceSaleWidget(self);
-                            wWidgetBalanceSale.renderElement();
-                            wWidgetBalanceSale.start();
-                            self.grid.addWidget(wWidgetBalanceSale.$el, 0, 0, wWidgetBalanceSale.size.width,  wWidgetBalanceSale.size.height, true);
-                        }
-
                         // *************************** Ingreso Egreso
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
                             return inv.name == 'ChartIngresoEgreso';
@@ -109,105 +87,39 @@ function dashboard_reporting_widget (instance, widget) {
                             self.grid.addWidget(wChartIngresoEgreso.$el, 0, 0, wChartIngresoEgreso.size.width,  wChartIngresoEgreso.size.height, true);
                         }
 
-                        // **************************** Historico de Facturas
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartInvoice';
-                        }));
-                        if(chart.length > 0){
-                            var wChartInvoice = new widgets.ChartInvoiceWidget(self);
-                            wChartInvoice.renderElement();
-                            wChartInvoice.start();
-                            self.grid.addWidget(wChartInvoice.$el, 0, 0, wChartInvoice.size.width,  wChartInvoice.size.height, true);
-                        }
-
-                        // *************************** Ventas - [SALE,POSORDER]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartPosOrder';
-                        }));
-                        if(chart.length > 0){
-                            var wChartPosOrder = new widgets.ChartPosOrderWidget(self);
-                            wChartPosOrder.renderElement();
-                            wChartPosOrder.start();
-                            self.grid.addWidget(wChartPosOrder.$el, 0, 0, wChartPosOrder.size.width,  wChartPosOrder.size.height, true);
-                        }
-
                         // *************************** Ranking de clientes [POSORDER - SALE]
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartPosOrderCustomer';
+                            return inv.name == 'ChartRankingCustomer';
                         }));
                         if(chart.length > 0){
-                            var wChartPosOrderCustomer = new widgets.ChartPosOrderCustomerWidget(self);
+                            var wChartPosOrderCustomer = new widgets.ChartRankingCustomer(self);
                             wChartPosOrderCustomer.renderElement();
                             wChartPosOrderCustomer.start();
                             self.grid.addWidget(wChartPosOrderCustomer.$el, 0, 0, wChartPosOrderCustomer.size.width,  wChartPosOrderCustomer.size.height, true);
                         }
 
-                        // *************************** Ranking de clientes [SALE]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartSaleOrderCustomer';
-                        }));
-                        if(chart.length > 0){
-                            var wChartSaleOrderCustomer = new widgets.ChartSaleOrderCustomerWidget(self);
-                            wChartSaleOrderCustomer.renderElement();
-                            wChartSaleOrderCustomer.start();
-                            self.grid.addWidget(wChartSaleOrderCustomer.$el, 0, 0, wChartSaleOrderCustomer.size.width,  wChartSaleOrderCustomer.size.height, true);
-                        }
-
                         // *************************** Ranking de Productos [POSORDER - SALE]
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartPosOrderProduct';
+                            return inv.name == 'ChartRankingProduct';
                         }));
                         if(chart.length > 0){
-                            var wChartPosOrderProduct = new widgets.ChartPosOrderProductWidget(self);
+                            var wChartPosOrderProduct = new widgets.ChartRankingProduct(self);
                             wChartPosOrderProduct.renderElement();
                             wChartPosOrderProduct.start();
                             self.grid.addWidget(wChartPosOrderProduct.$el, 0, 0, wChartPosOrderProduct.size.width,  wChartPosOrderProduct.size.height, true);
                         }
 
-                        // *************************** Ranking de Productos [SALE]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartSaleOrderProduct';
-                        }));
-                        if(chart.length > 0){
-                            var wChartSaleOrderProduct = new widgets.ChartSaleOrderProductWidget(self);
-                            wChartSaleOrderProduct.renderElement();
-                            wChartSaleOrderProduct.start();
-                            self.grid.addWidget(wChartSaleOrderProduct.$el, 0, 0, wChartSaleOrderProduct.size.width,  wChartSaleOrderProduct.size.height, true);
-                        }
-
                         // *************************** Vendedores [POSORDER - SALE]
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartPosOrderSalesman';
+                            return inv.name == 'ChartRankingSalesman';
                         }));
                         if(chart.length > 0){
-                            var wChartPosOrderSalesman = new widgets.ChartPosOrderSalesmanWidget(self);
+                            var wChartPosOrderSalesman = new widgets.ChartRankingSalesman(self);
                             wChartPosOrderSalesman.renderElement();
                             wChartPosOrderSalesman.start();
                             self.grid.addWidget(wChartPosOrderSalesman.$el, 0, 0, wChartPosOrderSalesman.size.width,  wChartPosOrderSalesman.size.height, true);
                         }
 
-                        // *************************** Vendedores [SALE]
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartSaleOrderSalesman';
-                        }));
-                        if(chart.length > 0){
-                            var wChartSaleOrderSalesman = new widgets.ChartSaleOrderSalesmanWidget(self);
-                            wChartSaleOrderSalesman.renderElement();
-                            wChartSaleOrderSalesman.start();
-                            self.grid.addWidget(wChartSaleOrderSalesman.$el, 0, 0, wChartSaleOrderSalesman.size.width,  wChartSaleOrderSalesman.size.height, true);
-                        }
-                        
-                        // *************************** Compras y Gastos
-                        var chart =  _.flatten(_.filter(ChartList,function (inv) {
-                            return inv.name == 'ChartPurchaseExpense';
-                        }));
-                        if(chart.length > 0){
-                            var wChartPurchaseExpense = new widgets.ChartPurchaseExpenseWidget(self);
-                            wChartPurchaseExpense.renderElement();
-                            wChartPurchaseExpense.start();
-                            self.grid.addWidget(wChartPurchaseExpense.$el, 0, 0, wChartPurchaseExpense.size.width,  wChartPurchaseExpense.size.height, true);
-                        }
-
                         // *************************** Ventas por Sucursal
                         var chart =  _.flatten(_.filter(ChartList,function (inv) {
                             return inv.name == 'ChartSaleByStore';

+ 18 - 15
static/src/js/main.js

@@ -9,18 +9,15 @@ openerp.eiru_reporting_dashboard = function (instance) {
     widget_reporting_base(instance, dashboard);
     dashboard_reporting_widget(instance, dashboard);
     
-    // Widgets
     try{
+        
         user(dashboard);
-        chart_invoice(dashboard);
-        chart_pos_order_customer(dashboard);
-        chart_pos_order_product(dashboard);
-        chart_pos_order_salesman(dashboard);
-        chart_pos_order(dashboard);
-        chart_purchase_expense(dashboard);
-        chart_ingreso_egreso(dashboard);
-        chart_sale_by_store(dashboard);
-        widget_pos_order(dashboard);
+        
+        /*===========
+            WIDGETS
+        ===========*/
+
+        widget_sale(dashboard);
         widget_purchase(dashboard);
         widget_expense(dashboard);
         widget_balance(dashboard);
@@ -28,11 +25,17 @@ openerp.eiru_reporting_dashboard = function (instance) {
         widget_bank(dashboard);
         widget_account_receivable(dashboard);
         widget_account_to_pay(dashboard);
-        widget_sale_order(dashboard);
-        widget_balance_sale(dashboard);
-        chart_sale_order_customer(dashboard);
-        chart_sale_order_product(dashboard);
-        chart_sale_order_salesman(dashboard);
+
+        /*==========
+            CHARTS
+        ==========*/
+
+        chart_ingreso_egreso(dashboard);
+        chart_sale_by_store(dashboard);
+        chart_ranking_customer(dashboard);
+        chart_ranking_product(dashboard);
+        chart_ranking_salesman(dashboard);
+
     }catch(e){
         // error
     }

+ 0 - 279
static/src/js/widgets/chart_invoice.js

@@ -1,279 +0,0 @@
-function chart_invoice (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartInvoiceWidget = widget.Base.extend({
-        template: 'ChartInvoice',
-        data: [],
-
-        events: {
-            'click .week': 'showWeeks',
-            'click .days': 'showDays',
-            'click .month': 'showMonths',
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-        fetchInitial:function() {
-            var self = this;
-            self.$el.block({
-                message: null,
-                overlayCSS: {
-                    backgroundColor: '#FAFAFA'
-                }
-            });
-
-            self.$el.find('.widget-content.widget-loading').css('display','flex');
-
-            self.fecthAccountInvoice().then(function (AccountInvoice) {
-                return AccountInvoice;
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.showMonths();
-            });
-        },
-  
-        // Obtener facturas
-        fecthAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','date_invoice','partner_id','amount_total','number','type'];
-            var domain = [['state','in',['paid','open']]];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        // Obtener facturas deproveedores por mes
-        getInAccountInvoice:function(mes) {
-            var self = this;
-            if (mes < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+mes;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+mes;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha & inv.type === 'in_invoice';
-            }));
-        },
-
-        // Obtener facturas de clientes por mes
-        getOutAccountInvoice:function(mes) {
-            var self = this;
-            if (mes < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+mes;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+mes;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha & inv.type === 'out_invoice';
-            }));
-        },
-
-        // Facturas de Proveedores por dias
-        getInDaysAccountInvoice:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type === 'in_invoice';
-            }));
-        },
-
-        // Facturas de Clientes por dias
-        getOutDaysAccountInvoice:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type === 'out_invoice';
-            }));
-        },
-
-        // Facturas de proveedor semana actual
-        getInWeekAccountInvoice:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).isoWeekday() === day & inv.type === 'in_invoice';
-            }));
-        },
-
-        // Facturas de clientes semana Actual
-        getOutWeekAccountInvoice:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).isoWeekday() === day & inv.type === 'out_invoice';
-            }));
-        },
-
-        // Mostrar grafico por dias
-        showDays: function() {
-            var self = this;
-            var title = [];
-            var invoices;
-            var dataIn = [];
-            var dataOut = [];
-            for (var i = 15; i >= 0; i--) {
-                invoices = self.getInDaysAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataIn.push(total);
-                title.push(moment().subtract(i, 'days').format('DD / MM'));
-            }
-            
-            for (var i = 15; i >= 0; i--) {
-                invoices = self.getOutDaysAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataOut.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataIn, dataOut, title);
-        },
-
-        // Mostrar por meses
-        showMonths: function() {
-            var self = this;
-            var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
-            var invoices;
-            var mes = 0;
-            var dataIn = [];
-            var dataOut = [];
-            for (var i = 1; i <= 12; i++) {
-                invoices = self.getInAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataIn.push(total);
-            }
-            for (var i = 1; i <= 12; i++) {
-                invoices = self.getOutAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataOut.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataIn, dataOut, title);
-        },
-
-        // Mostrar por semana Actual
-        showWeeks: function() {
-            var self = this;
-            var title = ['Lunes', 'Martes', 'Miercoles','Jueves','Viernes','Sabado','Domingo'];
-            var invoices;
-            var mes = 0;
-            var dataIn = [];
-            var dataOut = [];
-            for (var i = 1; i <= 7; i++) {
-                invoices = self.getInWeekAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataIn.push(total);
-            }
-            for (var i = 1; i <= 7; i++) {
-                invoices = self.getOutWeekAccountInvoice(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataOut.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataIn, dataOut, title);
-        },
-
-        // Generar Grafico
-        fetchChart: function (dataIn,dataOut,title) {
-            var self = this;
-            var label = title;
-            var bodyIn = dataIn;
-            var bodyOut = dataOut;
-            var item;
-
-            // Global method for setting Y axis number format.
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'line',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: 'Clientes  ',
-                            data: bodyOut,
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#64b5f6',
-                            borderWidth: 2,
-                            fill: false,
-                        },
-                        {
-                            label: 'Proveedores  ',                            
-                            data: bodyIn,
-                            backgroundColor: '#c8e6c9',
-                            borderColor: '#66bb6a',
-                            borderWidth: 2,
-                            fill: false,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: true,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 40,
-                            left : 10,
-                            rigth: 10,
-                        }
-                    },
-                }
-            });
-        },
-    });
-}

+ 0 - 323
static/src/js/widgets/chart_pos_order.js

@@ -1,323 +0,0 @@
-function chart_pos_order (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartPosOrderWidget = widget.Base.extend({
-        template: 'ChartPosOrder',
-        data: [],
-        events: {
-            'click .month': 'showMonth',
-            'click .week': 'showWeek',
-            'click .days': 'showDays',
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-
-        fetchInitial:function() {
-            var self = this;
-            self.$el.block({
-                message: null,
-                overlayCSS: {
-                    backgroundColor: '#FAFAFA'
-                }
-            });
-
-            self.$el.find('.widget-content.widget-loading').css('display','flex');
-
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function (ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal();
-            }).then(function (AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchPosOrder();
-            }).then(function (PosOrder) {
-                self.PosOrder = PosOrder;
-                return self.fetchAccountInvoice();
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.showMonth();
-            });
-        },
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
-            var ResUser = new model.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var store_ids = self.ResUser[0].store_id[0];
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-        
-        fetchPosOrder: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var fields = ['id','date_order','amount_total'];
-            var domain = [['state','not in',['draft','cancel']],['sale_journal','in',journal_ids] ];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var fields = ['id', 'name', 'date_invoice', 'amount_total'];
-            var domain = [['state', 'not in', ['draft','cancel']],['type','=','out_invoice'],['journal_id','in',journal_ids]];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        getMonthPosOrder:function(mes) {
-            var self = this;
-            if (mes < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+mes;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+mes;    
-            }
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                return moment(inv.date_order).format('YYYY-MM') === fecha;
-            }));
-        },
-
-        getWeekPosOrder:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                return moment(inv.date_order).week() === week & moment(inv.date_order).isoWeekday() === day;
-            }));
-        },
-
-        getDaysPosOrder:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                return moment(inv.date_order).format('YYYY-MM-DD') === date;
-            }));
-        },
-
-        getMonthAccountInvoice:function(mes) {
-            var self = this;
-            if (mes < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+mes;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+mes;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha;
-            }));
-        },
-
-        getWeekAccountInvoice:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).isoWeekday() === day;
-            }));
-        },
-
-        getDaysAccountInvoice:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date;
-            }));
-        },
-  
-        showMonth: function() {
-            var self = this;
-            var order;
-            var invoice;
-            var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
-            var data = [];
-            for (var i = 1; i <= 12; i++) {
-                order = self.getMonthPosOrder(i);
-                invoice = self.getMonthAccountInvoice(i);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total; 
-                data.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(data,title);
-        },
-
-        showWeek: function (){
-            var self = this;
-            var order;
-            var invoice;
-            var title = ['Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'];
-            var data = [];
-            for (var i = 1; i <= 7; i++) {
-                order = self.getWeekPosOrder(i);
-                order = self.getWeekAccountInvoice(i);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total;
-                data.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(data,title);
-        },
-
-        showDays: function() {
-            var self = this;
-            var order;
-            var invoice;
-            var title = [];
-            var data = [];
-            for (var i = 15; i >= 0; i--) {
-                order = self.getDaysPosOrder(i);
-                invoice = self.getDaysAccountInvoice(i);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total;
-                data.push(total);
-                title.push(moment().subtract(i, 'days').format('DD / MM'));
-            }
-
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(data, title);
-        },
-
-        fetchChart: function (data,title) {
-            var self = this;
-            var label = title;
-            var body = data;
-
-            // Global method for setting Y axis number format.
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'line',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#64b5f6',
-                            borderWidth: 2,
-                            fill: true,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 45,
-                            bottom: 40,
-                            left : 10,
-                            rigth: 10,
-                        }
-                    },
-                }
-            });
-        },
-
-        
-    });
-}

+ 0 - 276
static/src/js/widgets/chart_purchase_expense.js

@@ -1,276 +0,0 @@
-function chart_purchase_expense (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartPurchaseExpenseWidget = widget.Base.extend({
-        template: 'ChartPurchaseExpense',
-        data: [],
-
-        events: {
-            'click .month': 'showMonth',
-            'click .week': 'showWeek',
-            'click .days': 'showDays',
-        },
-        
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-
-        fetchInitial:function() {
-            var self = this;
-            self.$el.block({
-                message: null,
-                overlayCSS: {
-                    backgroundColor: '#FAFAFA'
-                }
-            });
-
-            self.$el.find('.widget-content.widget-loading').css('display','flex');
-
-            self.fecthAccountInvoice().then(function (AccountInvoice) {
-                return AccountInvoice;
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.showMonth();
-            });
-        },
-
-        fecthAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','date_invoice','amount_total','origin'];
-            var domain = [['state','in',['paid','open']],['type','=','in_invoice']];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        // Facturas de proveedor - Meses
-        getMonthAccountInvoicePurchase:function(month) {
-            var self = this;
-            if (month < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+month;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+month;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha & inv.origin !== false;
-            }));
-        },
-
-        getMonthAccountInvoiceExpense:function(month) {
-            var self = this;
-            if (month < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+month;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+month;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha & inv.origin === false;
-            }));
-        },
-
-        // Facturas de proveedor - Semana Actual
-        getWeekAccountInvoicePurchase:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & inv.origin !== false & moment(inv.date_invoice).isoWeekday() === day;
-            }));
-        },
-
-        getWeekAccountInvoiceExpense:function(day) {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & inv.origin === false & moment(inv.date_invoice).isoWeekday() === day;
-            }));
-        },
-
-        // Facturas de proveedor - 15 dias 
-        getDaysAccountInvoicePurchase:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.origin !== false;
-            }));
-        },
-        getDaysAccountInvoiceExpense:function(day) {
-            var self = this;
-            var date = moment().subtract(day, 'days').format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.origin === false;
-            }));
-        },
- 
-        showMonth: function() {
-            var self = this;
-            var invoices;
-            var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
-            var dataPurchase = [];
-            var dataExpense = [];
-
-            for (var i = 1; i <= 12; i++) {
-                invoices = self.getMonthAccountInvoicePurchase(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataPurchase.push(total)
-            }
-            
-            for (var i = 1; i <= 12; i++) {
-                invoices = self.getMonthAccountInvoiceExpense(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataExpense.push(total)
-            }
-
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataPurchase, dataExpense, title);
-        },
-
-        showWeek: function() {
-            var self = this;
-            var invoices;
-            var title = ['Lunes','Martes','Miercoles','Jueves','Viernes','Sabado','Domingo'];
-            var dataPurchase = [];
-            var dataExpense = [];
-
-            for (var i = 1; i <= 7; i++) {
-                invoices = self.getWeekAccountInvoicePurchase(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataPurchase.push(total);
-            }
-            
-            for (var i = 1; i <= 7; i++) {
-                invoices = self.getWeekAccountInvoiceExpense(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataExpense.push(total);
-            }
-
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataPurchase, dataExpense, title);
-        },
-
-        showDays: function() {
-            var self = this;
-            var title = [];
-            var invoices;
-            var dataPurchase = [];
-            var dataExpense = [];
-            for (var i = 15; i >= 0; i--) {
-                invoices = self.getDaysAccountInvoicePurchase(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataPurchase.push(total);
-                title.push(moment().subtract(i, 'days').format('DD / MM'));
-            }
-            
-            for (var i = 15; i >= 0; i--) {
-                invoices = self.getDaysAccountInvoiceExpense(i);
-                var total = _.reduce(_.map(invoices,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                dataExpense.push(total);
-            }
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(dataPurchase, dataExpense, title);
-        },
-
-        fetchChart: function (dataPurchase, dataExpense, title) {
-            var self = this;
-            var label = title;
-            var bodyPurchase = dataPurchase;
-            var bodyExpense = dataExpense;
-
-            // Global method for setting Y axis number format.
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'line',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: 'Compras  ',
-                            data: bodyPurchase,
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#64b5f6',
-                            borderWidth: 2,
-                            fill: false,
-                        },
-                        {
-                            label: 'Gastos  ',                            
-                            data: bodyExpense,
-                            backgroundColor: '#c8e6c9',
-                            borderColor: '#66bb6a',
-                            borderWidth: 2,
-                            fill: false,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: true,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 40,
-                            left : 10,
-                            rigth: 10,
-                        }
-                    },
-                }
-            });
-        },
-    });
-}

+ 0 - 315
static/src/js/widgets/chart_sale_by_store.js

@@ -1,315 +0,0 @@
-function chart_sale_by_store (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartSaleByStoreWidget = widget.Base.extend({
-        template: 'ChartSaleByStore',
-        data: [],
-        events: {
-            'click .month': 'showMonth',
-            'click .week': 'showWeek',
-            'click .days': 'showToday',
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-
-        fetchInitial:function() {
-            var self = this;
-            self.fetchAccountJournal().then(function (AccountJournal) {
-                return AccountJournal;
-            }).then(function (AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchPosOrder();
-            }).then(function (PosOrder) {
-                self.PosOrder = PosOrder;
-                return self.fetchAccountInvoice();
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.fetchResStore();
-            }).then(function (ResStore) {
-                self.ResStore = ResStore;
-                return self.showMonth();
-            });
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','=','sale']];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-        
-        fetchPosOrder: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var date = moment().add(-1, 'month').format('YYYY-MM-20 00:00:00');
-            var fields = ['id','date_order','amount_total','sale_journal'];
-            var domain = [['state','not in',['draft','cancel']],['date_order','>',date]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var desde = moment().format('YYYY-MM-01');
-            var hasta = moment().add(1,'months').format('YYYY-MM-01');
-            var fields = ['id', 'name', 'date_invoice', 'amount_total','journal_id'];
-            var domain = [['date_invoice','>=',desde], ['date_invoice','<',hasta],['state', 'not in', ['draft','cancel']],['type','=','out_invoice']];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchResStore: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','journal_ids'];
-            var ResStore = new model.web.Model('res.store');
-            ResStore.query(fields).filter().all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        /*===================================================
-        POS ORDER
-        ===================================================*/
-
-        getMonthPosOrder:function(id) {
-            var self = this;
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
-                return moment(utc._d).format('YYYY-MM') === moment().format('YYYY-MM') & inv.sale_journal[0] == journal_id[0].id;
-            }));
-        },
-
-        getWeekPosOrder:function(id) {
-            var self = this;
-            var week = moment().week();
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
-                utc = moment(utc._d).format('YYYY-MM-DD');
-                return moment(utc).week() === week & inv.sale_journal[0] == journal_id[0].id;
-            }));
-        },
-
-        getTodayPosOrder:function(id) {
-            var self = this;
-            var today = moment().format('YYYY-MM-DD');
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.PosOrder,function (inv) {
-                var utc = moment.utc(inv.date_order,'YYYY-MM-DD h:mm:ss A');
-                return moment(utc._d).format('YYYY-MM-DD') === today & inv.sale_journal[0] == journal_id[0].id;
-            }));
-        },
-
-        /*===================================================
-        ACCOUNT INVOICE
-        ===================================================*/
-
-        getMonthAccountInvoice:function(id) {
-            var self = this;
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === moment().format('YYYY-MM') & inv.journal_id[0] == journal_id[0].id;
-            }));
-        },
-
-        getWeekAccountInvoice:function(id) {
-            var self = this;
-            var week = moment().week();
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & inv.journal_id[0] == journal_id[0].id;
-            }));
-        },
-
-        getTodayAccountInvoice:function(id) {
-            var self = this;
-            var today = moment().format('YYYY-MM-DD');
-            var journal_id  = _.filter(self.AccountJournal,function (inv) {
-                return inv.store_ids[0] === id;
-            });
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === today & inv.journal_id[0] == journal_id[0].id;
-            }));
-        },
-  
-        showMonth: function() {
-            var self = this;
-            var order;
-            var invoice;
-            var title = [];
-            var data = [];            
-            _.each(self.ResStore, function(item){
-                title.push(item.name);
-                order = self.getMonthPosOrder(item.id);
-                invoice = self.getMonthAccountInvoice(item.id);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total;
-                data.push(total); 
-            });
-            self.fetchChart(data,title);
-        },
-
-        showWeek: function (){
-            var self = this;
-            var order;
-            var invoice;
-            var title = [];
-            var data = [];            
-            _.each(self.ResStore, function(item){
-                title.push(item.name);
-                order = self.getWeekPosOrder(item.id);
-                invoice = self.getWeekAccountInvoice(item.id);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total;
-                data.push(total); 
-            });
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(data,title);
-        },
-
-        showToday: function (){
-            var self = this;
-            var order;
-            var invoice;
-            var title = [];
-            var data = [];            
-            _.each(self.ResStore, function(item){
-                title.push(item.name);
-                order = self.getTodayPosOrder(item.id);
-                invoice = self.getTodayAccountInvoice(item.id);
-                var order_total = _.reduce(_.map(order,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var invoice_total = _.reduce(_.map(invoice,function(item) {
-                    return item.amount_total;
-                }),function(memo, num) {
-                    return memo + num;
-                },0);
-                var total = order_total + invoice_total;
-                data.push(total); 
-            });
-            self.$el.unblock();
-            self.$el.find('.widget-content.widget-loading').css('display','none');
-            self.fetchChart(data,title);
-        },
-
-        fetchChart: function (data,title) {
-            var self = this;
-            var label = title;
-            var body = data;
-
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'horizontalBar',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: '#bbdefb',
-                            borderColor: '#0288d1',
-                            borderWidth: 1,
-                            fill: true,
-                            datalabels : {
-                                align   : 'end',
-                                anchor : 'end',
-                                display: true,
-                                backgroundColor: function(context) {
-                                    return context.dataset.backgroundColor;
-                                },
-                                borderRadius: 4,
-                                color: '#001f3f',
-                                font: {
-                                    weight: 'bold'
-                                }
-                            }
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 45,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
-    });
-}

+ 0 - 276
static/src/js/widgets/chart_sale_order_customer.js

@@ -1,276 +0,0 @@
-function chart_sale_order_customer (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartSaleOrderCustomerWidget = widget.Base.extend({
-        template: 'ChartSaleOrderCustomer',
-        data: [],
-
-        events: {
-            
-        },
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-        fetchInitial:function() {
-            var self = this;
-
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal();
-            }).then(function(AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchAccountInvoice();
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.fetchResPartner();
-            }).then(function (ResPartner) {
-                self.ResPartner = ResPartner;
-                 return self.fetchResCompany();
-            }).then(function(ResCompany) {
-                self.ResCompany = ResCompany;
-                return self.fetchResCurrency();
-            }).then(function(ResCurrency) {
-                self.ResCurrency = ResCurrency;
-                return self.fetchCustomerRanking();
-            });
-        },
-
-        /* 
-            USER
-        */
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
-            var ResUser = new model.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var store_ids = self.ResUser[0].store_id[0];
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var desde = moment().format('YYYY-MM-01 00:00:00');
-            var hasta = moment().add(1,'months').format('YYYY-MM-01 00:00:00');
-            var defer = $.Deferred();
-            var fields = ['id','date_invoice','partner_id','amount_total','currency_id'];
-            var domain = [['state', 'in', ['open','paid']], ['date_invoice', '>=', desde],['date_invoice', '<', hasta],['type','=','out_invoice'],['journal_id','in',journal_ids]];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        // Consultar Clientes
-        fetchResPartner: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id', 'name'];
-            var domain = [['active', '=', true],['customer', '=', true]];
-            var ResPartner = new model.web.Model('res.partner');
-            ResPartner.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchResCompany: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
-            var ResCompany = new model.web.Model('res.company');
-            ResCompany.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        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;
-        },
-
-        getResCurrency: function (id) {
-            var self = this;
-            return _.filter(self.ResCurrency,function (item) {
-                return item.id === id;
-            })
-        },
-
-        getAccountInvoice:function(id) {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return inv.partner_id[0] === id;
-            }));
-        },
-
-        fetchCustomerRanking: function() {
-            var self = this;
-            console.log(self);
-            var PosOrder;
-            var AccountInvoice;
-            var ranking = [];
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            for (var i = 0; i < self.ResPartner.length; i++) {
-                var data = [];
-                AccountInvoice = self.getAccountInvoice(self.ResPartner[i].id);              
-                var account_invoice_amount = 0;
-                if(AccountInvoice.length > 0){
-                    _.each(AccountInvoice, function (item) {
-                        var currency = self.getResCurrency(item.currency_id[0]).shift();
-                        data.push({
-                            amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                        })
-                    });
-                    var account_invoice_amount = _.reduce(_.map(data,function(item) {
-                        return item.amount;
-                    }),function(memo, num) {
-                        return memo + num;
-                    },0);
-                }  
-                var amount = account_invoice_amount;
-                if(amount > 0 ){
-                    ranking.push({
-                        id: self.ResPartner[i].id,
-                        name: self.ResPartner[i].name,
-                        amount: amount
-                    });    
-                }
-            }
-            ranking.sort(function (a, b) {
-                return b.amount - a.amount
-            });
-            self.fetchChart(ranking);
-        },
-
-        // Generar Grafico
-        fetchChart: function (ranking) {
-            var self = this;
-            var label = [];
-            var body = [];
-            var item;
-            var rank = 7;
-            if (ranking.length < rank && ranking.length > 0 ){
-                rank= ranking.length;
-            }
-            for (var i = 0; i < rank; i++) {
-                if (ranking[i]) {
-                    item = ranking[i];
-                }
-                if (ranking.length === 0) {
-                    item = {};
-                    item.name = "N/A";
-                    item.amount = 0;
-                }
-                label.push(item.name);
-                body.push(item.amount);
-            }
-            
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'horizontalBar',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: 'Ranking  ',
-                            backgroundColor: '#bbdefb',
-                            borderColor: '#0288d1',
-                            borderWidth: 1,
-                            data: body,
-                            fill: false,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    legend: {
-                        display: false,
-                    },
-                    title: {
-                        display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 45,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                    elements: {
-                        line: {
-                            tension: 0.000001
-                        },
-                    },
-                }
-            });
-        },
-    });
-}

+ 0 - 235
static/src/js/widgets/chart_sale_order_product.js

@@ -1,235 +0,0 @@
-function chart_sale_order_product (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartSaleOrderProductWidget = widget.Base.extend({
-        template: 'ChartSaleOrderProduct',
-        data: [],
-
-        events: {
-            
-        },
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-        fetchInitial: function() {
-            var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal();
-            }).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.fecthProductProduct();
-            }).then(function(ProductProduct){
-                self.ProductProduct = ProductProduct;
-                return self.fetchProductRanking();
-            });
-        },
-
-        /* 
-            USER
-        */
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
-            var ResUser = new model.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var store_ids = self.ResUser[0].store_id[0];
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var desde = moment().format('YYYY-MM-01');
-            var hasta = moment().add(1,'months').format('YYYY-MM-01');
-            var fields = ['id', 'invoice_line', 'date_order'];
-            var domain = [['date_invoice', '>=', desde], ['date_invoice', '<', hasta], ['state', 'in', ['open','paid']],['journal_id','in',journal_ids],['type','=','out_invoice']];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchAccountInvoiceLine: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var invoice_line = _.flatten(_.map(self.AccountInvoice, function (item) {
-                return item.invoice_line;
-            }));
-            var fields = ['id', 'product_id', 'quantity'];
-            var domain = [['id','in', invoice_line]];
-            var AccountInvoiceLine = new model.web.Model('account.invoice.line');
-            AccountInvoiceLine.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fecthProductProduct: function () {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id', 'name_template','attribute_str'];
-            var domain = [['active', '=', true]];
-            var ProductProduct = new model.web.Model('product.product');
-            ProductProduct.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        getAccountInvoiceLine: function (id) {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoiceLine,function (item) {
-                return item.product_id[0] === id;
-            }));
-        },
-        
-        fetchProductRanking: function() {
-            var self = this;
-            var AccountInvoiceLine;
-            var ranking = [];
-            var quantity = 0;
-            var attribute;
-            for (var i = 0; i < self.ProductProduct.length; i++) {
-                AccountInvoiceLine = self.getAccountInvoiceLine(self.ProductProduct[i].id);
-                if (AccountInvoiceLine.length > 0) {
-                    var invoice_quantity = _.reduce(_.map(AccountInvoiceLine, function (map) {
-                        return map.quantity
-                    }), function (meno,num) {
-                        return meno + num
-                    }, 0);
-                    if(self.ProductProduct[i].attribute_str){
-                        attribute = '*' + self.ProductProduct[i].attribute_str;
-                    }else{
-                        attribute = ' ';
-                    }
-                    ranking.push({
-                        id: self.ProductProduct[i].id,
-                        product: self.ProductProduct[i].name_template + ' ' + attribute,
-                        qty: invoice_quantity,
-                    });
-                }
-            }
-            ranking.sort(function(a, b) {
-                return b.qty - a.qty
-            });
-            self.fetchChart(ranking);
-        },     
-
-
-        fetchChart: function (ranking){
-            var self = this;
-            var label = [];
-            var body = [];
-            var rank = 7;
-            var item;
-
-            for (var i = 0; i < rank; i++) {
-                if (ranking[i]){
-                    item = ranking[i];
-                }else{
-                    item = {};
-                    item.product = "N/A";
-                    item.qty = 0;
-                }
-                var name = item.product.split('*');
-                if (name.length === 1) {
-                        label.push(name[0]);
-                }else{
-                    label.push(name[0]+"("+name[name.length-1]+")");
-                }
-                body.push(item.qty);
-            }
-
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'horizontalBar',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: 'Productos ',
-                            borderWidth: 2,
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#64b5f6',
-                            data: body,
-                            fill: true,
-                        },
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 40,
-                            left: 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
-    });
-}

+ 0 - 256
static/src/js/widgets/chart_sale_order_salesman.js

@@ -1,256 +0,0 @@
-function chart_sale_order_salesman (widget) {
-    "use strict";
-
-    var model = openerp;
-
-    widget.ChartSaleOrderSalesmanWidget = widget.Base.extend({
-        template: 'ChartSaleOrderSalesman',
-        events: {
-
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 6,
-                height: 4
-            });
-        },
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-        fetchInitial:function() {
-            var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser();
-            }).then(function(ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal(self.CurrentUser);
-            }).then(function(AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchAccountInvoice();
-            }).then(function (AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.fetchResCompany(self.CurrentUser);
-            }).then(function(ResCompany) {
-                self.ResCompany = ResCompany;
-                return self.fetchResCurrency();
-            }).then(function(ResCurrency) {
-                self.ResCurrency = ResCurrency;
-                return self.fetchProductRanking();
-            });
-        },
-
-        /* 
-            USER
-        */
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id','company_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;
-        },
-
-        fetchAccountJournal: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var user = _.flatten(_.filter(self.ResUser,function (inv) {
-                return inv.id === id;
-            }));
-            var store_ids = user[0].store_id[0];
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var desde = moment().format('YYYY-MM-01');
-            var hasta = moment().add(1,'months').format('YYYY-MM-01');
-            var fields = ['id', 'invoice_line', 'date_order','user_id','amount_total','currency_id'];
-            var domain = [['date_invoice', '>=', desde], ['date_invoice', '<', hasta], ['state', 'in', ['open','paid']],['journal_id','in',journal_ids],['type','=','out_invoice']];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchResCompany: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var user = _.flatten(_.filter(self.ResUser,function (inv) {
-                return inv.id === id;
-            }));
-            var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', user[0].company_id[0]]];
-            var ResCompany = new model.web.Model('res.company');
-            ResCompany.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        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;
-        },
-
-        getResCurrency: function (id) {
-            var self = this;
-            return _.filter(self.ResCurrency,function (item) {
-                return item.id === id;
-            })
-        },
-
-        getAccountInvoice:function(id) {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return inv.user_id[0] === id;
-            }));
-        },
-
-        fetchProductRanking: function() {
-            var self = this;
-            var AccountInvoice;
-            var ranking = [];
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            for (var i = 0; i < self.ResUser.length; i++) {
-                var data = [];
-                var amount = 0;
-                AccountInvoice = self.getAccountInvoice(self.ResUser[i].id);
-                if (AccountInvoice.length > 0) {
-                    _.each(AccountInvoice, function (item) {
-                        var currency = self.getResCurrency(item.currency_id[0]).shift();
-                        data.push({
-                            amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                        })
-                    });
-                    if(data.length > 0){
-                        amount = _.reduce(_.map(data, function (map) {
-                            return map.amount;
-                        }), function (memo, num) {
-                            return memo + num;
-                        }); 
-                    }
-                    ranking.push({
-                        id: self.ResUser[i].id,
-                        name: self.ResUser[i].name,
-                        amount: accounting.formatNumber(amount,0,"",","),
-                    });
-                }
-            }
-            ranking.sort(function (a, b) {
-                return b.amount - a.amount
-            });
-            self.fetchChart(ranking);
-        },
-
-        fetchChart: function (ranking) {
-            var self = this;
-            var label = [];
-            var body = [];
-            var item;
-            var rank = 7;
-
-            if (ranking.length < rank && ranking.length > 0 )
-                rank= ranking.length;
-
-            for (var i = 0; i < rank; i++) {
-                if (ranking[i]) {
-                    item = ranking[i];
-                }
-                if (ranking.length === 0) {
-                    item = {};
-                    item.name = "N/A";
-                    item.amount = 0;
-                }
-                label.push(item.name);
-                body.push(item.amount);
-            }
-            // Global method for setting Y axis number format.
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-            var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'horizontalBar',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: 'Ventas  ',
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#64b5f6',
-                            borderWidth: 1,
-                            data: body,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 40,
-                            left: 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
-    });
-}

+ 1 - 1
static/src/js/widgets/widget_account_receivable.js

@@ -131,7 +131,7 @@ function widget_account_receivable(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);

+ 1 - 1
static/src/js/widgets/widget_account_to_pay.js

@@ -131,7 +131,7 @@ function widget_account_to_pay(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);

+ 64 - 24
static/src/js/widgets/widget_balance.js

@@ -6,6 +6,7 @@ function widget_balance(widget) {
 
     widget.WidgetBalanceWidget = widget.Base.extend({
         template: 'WidgetBalance',
+        modules: ['point_of_sale'],
         month: 0,
         week: 0,
         today: 0,
@@ -29,11 +30,21 @@ function widget_balance(widget) {
             self.fetchInitial();
         },
 
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
         fetchInitial: function(){
             var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -57,6 +68,22 @@ function widget_balance(widget) {
             });
         },
 
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
         /* 
             USER
         */
@@ -93,7 +120,7 @@ function widget_balance(widget) {
             var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
                 return item.id;
             }));
-             var date = moment().add(-1, 'month').format('YYYY-MM-23 HH:mm:ss');
+            var date = moment().add(-1, 'month').format('YYYY-MM-23 HH:mm:ss');
             var fields = ['id','type','date_invoice','amount_total','currency_id'];
             var domain = [['state', 'not in', ['draft','cancel']],['type','in',['in_invoice','out_invoice']],['journal_id','in',journal_ids],['date_invoice','>',date]];
             var AccountInvoice = new model.web.Model('account.invoice');
@@ -106,18 +133,23 @@ function widget_balance(widget) {
         fetchPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var date = moment().add(-1, 'month').format('YYYY-MM-23 HH:mm:ss');
-            var fields = ['id', 'name', 'date_order', 'amount_total','sale_journal'];
-            var domain = [['state', 'not in', ['draft','cancel']],['sale_journal','in',journal_ids],['date_order','>',date]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
+                    return item.id;
+                }));
+                var date = moment().add(-1, 'month').format('YYYY-MM-23 HH:mm:ss');
+                var fields = ['id', 'name', 'date_order', 'amount_total','sale_journal'];
+                var domain = [['state', 'not in', ['draft','cancel']],['sale_journal','in',journal_ids],['date_order','>',date]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function(results) {
+                    defer.resolve(results);
+                });
+                return defer;
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
         },
 
         fetchResCompany: function() {
@@ -436,11 +468,15 @@ function widget_balance(widget) {
             }else{
                 var percentage = 0;
             }
-            var chart4 = new ldBar("#circle-balance",{
-                'stroke':'#0288d1',
-                'stroke-width':'10'
+            $("#circle-balance").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: percentage,
+                fontColor: '#0288d1',
+                foregroundColor: '#0288d1',
+                percentageTextSize: 35,
             });
-            chart4.set(percentage);
             self.percentage = percentage;
             
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
@@ -473,11 +509,15 @@ function widget_balance(widget) {
                 self.removeModal(e);
             })
 
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#0288d1',
+            $("#myItemModal").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: self.percentage,
+                fontColor: '#0288d1',
+                foregroundColor: '#0288d1',
+                percentageTextSize: 35,
             });
-
-            chartX.set(self.percentage);
         },
 
         removeModal: function (e) {

+ 0 - 406
static/src/js/widgets/widget_balance_sale.js

@@ -1,406 +0,0 @@
-function widget_balance_sale(widget) {
-    "use strict";
-
-    var model = openerp;
-    var Qweb = openerp.web.qweb;
-
-    widget.WidgetBalanceSaleWidget = widget.Base.extend({
-        template: 'WidgetBalanceSale',
-        month: 0,
-        week: 0,
-        today: 0,
-        data: 0,
-        objective: 0,
-        percentage: 0, 
-
-        events: {
-           'click .number': 'showModal',
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 3,
-                height: 2
-            });
-        },
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-
-        fetchInitial: function(){
-            var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal();
-            }).then(function(AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchAccountInvoice();
-            }).then(function(AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.fetchResCompany();
-            }).then(function(ResCompany) {
-                self.ResCompany = ResCompany;
-                return self.fetchResCurrency();
-            }).then(function(ResCurrency) {
-                self.ResCurrency = ResCurrency;
-                return self.fetchDashboardObjetive();
-            }).then(function(DashboardObjetive) {
-                self.DashboardObjetive = DashboardObjetive;
-                return self.showThisMonth();
-            });
-        },
-
-        /* 
-            USER
-        */
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
-            var ResUser = new model.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var store_ids = self.ResUser[0].store_id[0];
-            var fields = ['id', 'name', 'store_ids'];
-            var domain = [['type','in',['sale','purchase']],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var fields = ['id','type','date_invoice','amount_total','currency_id'];
-            var domain = [['state', 'not in', ['draft','cancel']],['type','in',['in_invoice','out_invoice']],['journal_id','in',journal_ids]];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchResCompany: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
-            var ResCompany = new model.web.Model('res.company');
-            ResCompany.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        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;
-        },
-
-        fetchDashboardObjetive : function(){
-            var self = this;
-            var defer = $.Deferred();
-            var store_id = self.ResUser[0].store_id[0];
-            var date_min = moment().format('YYYY-MM-01');
-            var date_max = moment().add(1, 'month').format('YYYY-MM-01');
-            var fields = ['id','store_id', 'date', 'sale_objetive', 'purchase_limit', 'expense_limit', 'expected_profit'];
-            var domain = [['date', '>=', date_min],['date', '<', date_max],['store_id','=',store_id]];
-            var DashboardObjetive = new model.web.Model('dashboard.objetive');
-            DashboardObjetive.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        getResCurrency: function (id) {
-            var self = this;
-            return _.filter(self.ResCurrency,function (item) {
-                return item.id === id;
-            })
-        },
-
-        /* 
-            ACCOUNT INVOICE - TODAY
-        */
-
-        getTodayInAccountInvoice:function() {
-            var self = this;
-            var date = moment().format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type == 'in_invoice';
-            }));
-        },
-
-        getTodayOutAccountInvoice:function() {
-            var self = this;
-            var date = moment().format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date & inv.type == 'out_invoice';
-            }));
-        },
-
-        /* 
-            ACCOUNT INVOICE - WEEK
-        */
-
-        getThisWeekInAccountInvoice:function() {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY') & inv.type == 'in_invoice';
-            }));
-        },
-
-        getThisWeekOutAccountInvoice:function() {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY') & inv.type == 'out_invoice';
-            }));
-        },
-
-        /* 
-            ACCOUNT INVOICE - MONTH
-        */
-
-        getThisMonthInAccountInvoice:function() {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM') & inv.type == 'in_invoice';
-            }));
-        },
-
-        getThisMonthOutAccountInvoice:function() {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM') & inv.type == 'out_invoice';
-            }));
-        },
-
-        /* 
-            TODAY
-        */
-
-        showToday: function () {
-            var self = this;
-            var amount_order = 0;
-            var invoice_in_amount = 0;
-            var invoice_out_amount = 0;
-            var balance = 0;
-            var in_array = [];
-            var out_array = [];
-            var in_invoice = self.getTodayInAccountInvoice();
-            var out_invoice = self.getTodayOutAccountInvoice();
-            if(in_invoice.length > 0){
-                _.each(in_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    in_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_in_amount = _.reduce(_.map(in_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            if(out_invoice.length > 0){
-                _.each(out_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    out_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_out_amount = _.reduce(_.map(out_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            balance = invoice_out_amount - invoice_in_amount;
-            self.today = balance;
-        },
-
-        /* 
-            WEEK
-        */
-
-        showThisWeek: function () {
-            var self = this;
-            var amount_order = 0;
-            var invoice_in_amount = 0;
-            var invoice_out_amount = 0;
-            var balance = 0;
-            var in_array = [];
-            var out_array = [];
-            var in_invoice = self.getThisWeekInAccountInvoice();
-            var out_invoice = self.getThisWeekOutAccountInvoice();
-            if(in_invoice.length > 0){
-                _.each(in_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    in_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_in_amount = _.reduce(_.map(in_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            if(out_invoice.length > 0){
-                _.each(out_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    out_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_out_amount = _.reduce(_.map(out_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            balance = invoice_out_amount - invoice_in_amount;
-            self.week = balance;
-        },
-
-        /* 
-            MONTH
-        */
-
-        showThisMonth: function () {
-            var self = this;
-            if(self.DashboardObjetive.length > 0){
-                self.objective = self.DashboardObjetive.shift().expected_profit;   
-            }else{
-                self.objective = 0;    
-            }
-            var amount_order = 0;
-            var invoice_in_amount = 0;
-            var invoice_out_amount = 0;
-            var balance = 0;
-            var in_array = [];
-            var out_array = [];
-            var in_invoice = self.getThisMonthInAccountInvoice();
-            var out_invoice = self.getThisMonthOutAccountInvoice();
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            if(in_invoice.length > 0){
-                _.each(in_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    in_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_in_amount = _.reduce(_.map(in_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            if(out_invoice.length > 0){
-                _.each(out_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    out_array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_out_amount = _.reduce(_.map(out_array, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            balance = invoice_out_amount - invoice_in_amount;           
-            self.month = balance;
-            if(self.objective > 0){ 
-                var percentage = (balance*100)/self.objective;  
-            }else{
-                var percentage = 0;
-            }
-            var chart4 = new ldBar("#circle-balancesale",{
-                'stroke':'#0288d1',
-                'stroke-width':'10'
-            });
-            chart4.set(percentage);
-            self.percentage = percentage;
-            self.$el.find('.widget-content').find('a').text(accounting.formatMoney(balance, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
-        },
-
-        /* 
-            MODAL
-        */
-
-        showModal: function (e) {
-            var self = this;
-            self.showThisWeek();
-            self.showToday();
-            var titleData = [
-                {
-                    title: "Balance"
-                }
-            ];
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            var modal = Qweb.render('WidgetModal', {
-                modalTitle: titleData,
-                objective: accounting.formatMoney(self.objective, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                today: accounting.formatMoney(self.today, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                week: accounting.formatMoney(self.week, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                month: accounting.formatMoney(self.month, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-            });
-            $('.openerp_webclient_container').after(modal);
-            $('.widget-modal').modal()
-            $('.widget-modal').on('hidden.bs.modal', function (e) {
-                self.removeModal(e);
-            })
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#0288d1',
-            });
-            chartX.set(self.percentage);
-        },
-
-        removeModal: function (e) {
-            $('.widget-modal').remove();
-            $('.modal-backdrop').remove();
-        },
-
-    });
-}

+ 17 - 30
static/src/js/widgets/widget_bank.js

@@ -22,20 +22,9 @@ function widget_bank(widget) {
 
         fetchInitial: function(){
             var self = this;
-            self.$el.find('#morosidad').block({
-                message: null,
-                overlayCSS: {
-                    backgroundColor: '#FAFAFA'
-                }
-            });
-            self.$el.find('.widget-content.widget-loading').css('display','flex');
-
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
+            self.fetchResUser().then(function (ResUser) {
+                return ResUser;
+            }).then(function (ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -53,20 +42,11 @@ function widget_bank(widget) {
             });
         },
 
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
+        fetchResUser: function() {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
+            var domain = [['id','=',self.session.uid]];
             var ResUser = new model.web.Model('res.users');
             ResUser.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -95,7 +75,7 @@ function widget_bank(widget) {
             var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
                 return item.id;
             }));
-            var fields = ['id', 'name', 'date', 'balance_end'];
+            var fields = ['id', 'name', 'date', 'balance_end','currency'];
             var domain = [['state', 'in', ['draft','open']],['journal_id','in',journal_ids]];
             var AccountBankStatement = new model.web.Model('account.bank.statement');
             AccountBankStatement.query(fields).filter(domain).all().then(function(results) {
@@ -109,7 +89,7 @@ function widget_bank(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -144,13 +124,20 @@ function widget_bank(widget) {
             var statement = self.AccountBankStatement;
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(statement.length > 0){
-                amount = _.reduce(_.map(statement, function (map) {
-                    return map.balance_end;
+                var array = [];
+                _.each(statement, function (item) {
+                    var currency = self.getResCurrency(item.currency[0]).shift();
+                    array.push({
+                        amount: item.balance_end * (CurrencyBase.rate_silent / currency.rate_silent),
+                    })
+                });
+                var invoice_total = 0;
+                amount = _.reduce(_.map(array, function (map) {
+                    return map.amount;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
-            self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
     });

+ 17 - 29
static/src/js/widgets/widget_cash.js

@@ -22,20 +22,9 @@ function widget_cash(widget) {
 
         fetchInitial: function(){
             var self = this;
-            self.$el.find('#morosidad').block({
-                message: null,
-                overlayCSS: {
-                    backgroundColor: '#FAFAFA'
-                }
-            });
-            self.$el.find('.widget-content.widget-loading').css('display','flex');
-
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
+            self.fetchResUser().then(function (ResUser) {
+                return ResUser;
+            }).then(function (ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -53,19 +42,11 @@ function widget_cash(widget) {
             });
         },
 
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
+        fetchResUser: function() {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
+            var domain = [['id','=',self.session.uid]];
             var ResUser = new model.web.Model('res.users');
             ResUser.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -94,7 +75,7 @@ function widget_cash(widget) {
             var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
                 return item.id;
             }));
-            var fields = ['id', 'name', 'date', 'balance_end'];
+            var fields = ['id', 'name', 'date', 'balance_end','currency'];
             var domain = [['state', 'in', ['open']],['journal_id','in',journal_ids]];
             var AccountBankStatement = new model.web.Model('account.bank.statement');
             AccountBankStatement.query(fields).filter(domain).all().then(function(results) {
@@ -108,7 +89,7 @@ function widget_cash(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -143,13 +124,20 @@ function widget_cash(widget) {
             var statement = self.AccountBankStatement;
             var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
             if(statement.length > 0){
-                amount = _.reduce(_.map(statement, function (map) {
-                    return map.balance_end;
+                var array = [];
+                _.each(statement, function (item) {
+                    var currency = self.getResCurrency(item.currency[0]).shift();
+                    array.push({
+                        amount: item.balance_end * (CurrencyBase.rate_silent / currency.rate_silent),
+                    })
+                });
+                var invoice_total = 0;
+                amount = _.reduce(_.map(array, function (map) {
+                    return map.amount;
                 }), function (memo, num) {
                     return memo + num;
                 });
             }
-            self.$el.find('.widget-content.widget-loading').css('display','none');
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
     });

+ 27 - 27
static/src/js/widgets/widget_expense.js

@@ -31,11 +31,8 @@ function widget_expense(widget) {
 
         fetchInitial: function(){
             var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
+            self.fetchResUser().then(function (ResUser) {
+                return ResUser;
             }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
@@ -61,19 +58,11 @@ function widget_expense(widget) {
             USER
         */
 
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
         fetchResUser: function(id) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
+            var domain = [['id','=',self.session.uid]];
             var ResUser = new model.web.Model('res.users');
             ResUser.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -116,7 +105,7 @@ function widget_expense(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -279,18 +268,25 @@ function widget_expense(widget) {
                 });
             }
             self.month = accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
+            
             if(self.objective > 0){ 
                 var percentage = (amount*100)/self.objective;    
             }else{
                 var percentage = 0;
             }
-            var chart3 = new ldBar("#circle-expense",{
-                'stroke':'#ef6c00',
-                'stroke-width':'10'
-            });
-            chart3.set(percentage);
-            self.percentage = percentage;
 
+            self.percentage = percentage;
+            
+            $("#circle-expense").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: percentage,
+                fontColor: '#ef6c00',
+                foregroundColor: '#ef6c00',
+                percentageTextSize: 35,
+            });
+            
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
 
@@ -356,12 +352,16 @@ function widget_expense(widget) {
             $('.widget-modal').on('hidden.bs.modal', function (e) {
                 self.removeModal(e);
             })
-
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#ef6c00',
-            });
-
-            chartX.set(self.percentage);
+            
+            $("#myItemModal").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: self.percentage,
+                fontColor: '#ef6c00',
+                foregroundColor: '#ef6c00',
+                percentageTextSize: 35,
+           });
 
             self.fetchChart(self.data);
         },

+ 17 - 9
static/src/js/widgets/widget_purchase.js

@@ -115,7 +115,7 @@ function widget_purchase(widget) {
             var self = this;
             var defer = $.Deferred();
             var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
+            var domain = [['id', '=', self.session.company_id]];
             var ResCompany = new model.web.Model('res.company');
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
@@ -286,11 +286,15 @@ function widget_purchase(widget) {
             }else{
                 var percentage = 0;
             }
-            var chart2 = new ldBar("#circle-purchase",{
-                'stroke':'#f9a825',
-                'stroke-width':'10'
+            $("#circle-purchase").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: percentage,
+                fontColor: '#f9a825',
+                foregroundColor: '#f9a825',
+                percentageTextSize: 35,
             });
-            chart2.set(percentage);
             self.percentage = percentage;
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
         },
@@ -354,12 +358,16 @@ function widget_purchase(widget) {
                 self.removeModal(e);
             })
 
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#f9a825',
+            $("#myItemModal").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: self.percentage,
+                fontColor: '#f9a825',
+                foregroundColor: '#f9a825',
+                percentageTextSize: 35,
             });
 
-            chartX.set(self.percentage);
-
             self.fetchChart(self.data);
         },
 

+ 80 - 43
static/src/js/widgets/widget_pos_order.js → static/src/js/widgets/widget_sale.js

@@ -1,11 +1,12 @@
-function widget_pos_order(widget) {
+function widget_sale(widget) {
     "use strict";
 
     var model = openerp;
     var Qweb = openerp.web.qweb;
 
-    widget.WidgetPosOrderWidget = widget.Base.extend({
-        template: 'WidgetPosOrder',
+    widget.WidgetSale = widget.Base.extend({
+        template: 'WidgetSale',
+        modules: ['point_of_sale'],
         month: 0,
         week: 0,
         today: 0,
@@ -29,11 +30,21 @@ function widget_pos_order(widget) {
             self.fetchInitial();
         },
 
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
         fetchInitial: function(){
             var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function(ResUser) {
                 self.ResUser = ResUser;
                 return self.fetchAccountJournal();
             }).then(function(AccountJournal) {
@@ -57,6 +68,22 @@ function widget_pos_order(widget) {
             });
         },
 
+        /* 
+            IR MODULES
+        */
+       
+        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;
+        },
+
         /* 
             USER
         */
@@ -73,34 +100,39 @@ function widget_pos_order(widget) {
             return defer;
         },
 
-        fetchAccountJournal: function() {
+        fetchAccountJournal: function(){
             var self = this;
             var defer = $.Deferred();
             var store_ids = self.ResUser[0].store_id[0];
             var fields = ['id','name','store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
+            var domain = [['active','=',true],['type','=','sale'],['store_ids','in',store_ids]];
             var AccountJournal = new model.web.Model('account.journal');
             AccountJournal.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
-            });
-
+            });    
             return defer;
         },
 
         fetchPosOrder: function() {
             var self = this;
             var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
+            var modules = self.checkModel('point_of_sale');
+            if (modules.length > 0){
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
                 return item.id;
-            }));
-            var date = moment().add(-1, 'month').format('YYYY-MM-23 00:00:00');
-            var fields = ['id', 'name', 'date_order', 'amount_total','sale_journal'];
-            var domain = [['state', 'not in', ['draft','cancel']],['sale_journal','in',journal_ids],['date_order','>',date]];
-            var PosOrder = new model.web.Model('pos.order');
-            PosOrder.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
+                }));
+                var date = moment().format('YYYY-01-01 00:00:00');
+                var fields = ['id', 'name', 'date_order', 'amount_total','sale_journal'];
+                var domain = [['sale_journal','in',journal_ids],['state', 'not in', ['draft','cancel']],['date_order','>=',date]];
+                var PosOrder = new model.web.Model('pos.order');
+                PosOrder.query(fields).filter(domain).all().then(function(results) {
+                    defer.resolve(results);
+                });
+                return defer; 
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
         },
 
         fetchAccountInvoice: function() {
@@ -109,15 +141,13 @@ function widget_pos_order(widget) {
             var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
                 return item.id;
             }));
-            var desde = moment().format('YYYY-MM-01');
-            var hasta = moment().add(1,'months').format('YYYY-MM-01');
+            var date = moment().format('YYYY-01-01');
             var fields = ['id','name','amount_total','date_invoice','currency_id'];
-            var domain = [['state', 'not in', ['draft','cancel']],['type','=','out_invoice'],['journal_id','in',journal_ids],['date_invoice','>=',desde],['date_invoice','<',hasta]];
+            var domain = [['state', 'not in', ['draft','cancel']],['type','=','out_invoice'],['journal_id','in',journal_ids],['date_invoice','>=',date]];
             var AccountInvoice = new model.web.Model('account.invoice');
             AccountInvoice.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
-
             return defer;
         },
 
@@ -130,7 +160,6 @@ function widget_pos_order(widget) {
             ResCompany.query(fields).filter(domain).all().then(function (results) {
                 defer.resolve(results);
             });
-
             return defer;
         },
 
@@ -168,9 +197,9 @@ function widget_pos_order(widget) {
             })
         },
 
-        /*
+        /*=============
             POS ORDER     
-        */
+        =============*/
        
         getTodayPosOrder:function() {
             var self = this;
@@ -199,9 +228,9 @@ function widget_pos_order(widget) {
             }));
         },
 
-        /* 
+        /*====================== 
             POS ORDER BY MONTH
-        */
+        ======================*/
 
         getMonthPosOrder:function(mes) {
             var self = this;
@@ -216,9 +245,9 @@ function widget_pos_order(widget) {
             }));
         },
 
-        /*
+        /*===================
             ACCOUNT INVOICE
-        */
+        ===================*/
 
         getTodayAccountInvoice:function() {
             var self = this;
@@ -243,9 +272,9 @@ function widget_pos_order(widget) {
             }));
         },
 
-        /* 
+        /*============================ 
             ACCOUNT INVOICE BY MONTH
-        */
+        ============================*/
 
         getMonthAccountInvoice:function(mes) {
             var self = this;
@@ -382,12 +411,15 @@ function widget_pos_order(widget) {
                 var percentage = 0;
             }
 
-            var chart1 = new ldBar("#circle-posorder",{
-                'stroke':'#43a047',
-                'stroke-width':'10'
+            $("#circle-posorder").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: percentage,
+                fontColor: '#43a047',
+                foregroundColor: '#43a047',
+                percentageTextSize: 35,
             });
-            
-            chart1.set(percentage);
 
             self.percentage = percentage;
             self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
@@ -431,9 +463,9 @@ function widget_pos_order(widget) {
             self.data = data;
         },
 
-        /* 
+        /*========= 
             MODAL
-        */
+        =========*/
 
         showModal: function (e) {
             var self = this;
@@ -460,10 +492,15 @@ function widget_pos_order(widget) {
                 self.removeModal(e);
             })
 
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#43a047',
+            $("#myItemModal").circliful({
+                animationStep: 10,
+                foregroundBorderWidth: 15,
+                backgroundBorderWidth: 1,
+                percent: self.percentage,
+                fontColor: '#43a047',
+                foregroundColor: '#43a047',
+                percentageTextSize: 35,
             });
-            chartX.set(self.percentage);
 
             self.fetchChart(self.data);
         },

+ 0 - 449
static/src/js/widgets/widget_sale_order.js

@@ -1,449 +0,0 @@
-function widget_sale_order(widget) {
-    "use strict";
-
-    var model = openerp;
-    var Qweb = openerp.web.qweb;
-
-    widget.WidgetSaleOrderWidget = widget.Base.extend({
-        template: 'WidgetSaleOrder',
-        month: 0,
-        week: 0,
-        today: 0,
-        data: 0,
-        objective: 0,
-        percentage: 0,
-
-        events: {
-            'click .number': 'showModal',
-        },
-
-        init: function (parent) {
-            this._super(parent, {
-                width: 3,
-                height: 2
-            });   
-        }, 
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-        },
-
-        fetchInitial: function(){
-            var self = this;
-            self.fetchCurrentUser().then(function (CurrentUser) {
-                return CurrentUser;
-            }).then(function (CurrentUser) {
-                self.CurrentUser = CurrentUser;
-                return self.fetchResUser(CurrentUser);
-            }).then(function(ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchAccountJournal();
-            }).then(function(AccountJournal) {
-                self.AccountJournal = AccountJournal;
-                return self.fetchAccountInvoice();
-            }).then(function(AccountInvoice) {
-                self.AccountInvoice = AccountInvoice;
-                return self.fetchResCompany();
-            }).then(function(ResCompany) {
-                self.ResCompany = ResCompany;
-                return self.fetchResCurrency();
-            }).then(function(ResCurrency) {
-                self.ResCurrency = ResCurrency;
-                return self.fetchDashboardObjetive();
-            }).then(function(DashboardObjetive) {
-                self.DashboardObjetive = DashboardObjetive;
-                return self.showThisMonth();
-            });
-        },
-
-        /* 
-            USER
-        */
-
-        fetchCurrentUser: function() {
-            var self = this;
-            var ResUser = new model.web.Model('res.users');
-            return ResUser.call('get_user', {
-                context: new model.web.CompoundContext()
-            });
-        },
-
-        fetchResUser: function(id) {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name','store_id'];
-            var domain = [['id','=',id]];
-            var ResUser = new model.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountJournal: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var store_ids = self.ResUser[0].store_id[0];
-            var fields = ['id','name','store_ids'];
-            var domain = [['type','=','sale'],['store_ids','in',store_ids]];
-            var AccountJournal = new model.web.Model('account.journal');
-            AccountJournal.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchAccountInvoice: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var journal_ids = _.flatten(_.map(this.AccountJournal, function (item) {
-                return item.id;
-            }));
-            var fields = ['id','name','amount_total','date_invoice','currency_id'];
-            var domain = [['state', 'not in', ['draft','cancel']],['type','=','out_invoice'],['journal_id','in',journal_ids]];
-            var AccountInvoice = new model.web.Model('account.invoice');
-            AccountInvoice.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        fetchResCompany: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name', 'currency_id'];
-            var domain = [['id', '=', 1]];
-            var ResCompany = new model.web.Model('res.company');
-            ResCompany.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-
-            return defer;
-        },
-
-        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 ResCurrecy = new model.web.Model('res.currency');
-            ResCurrecy.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        fetchDashboardObjetive : function(){
-            var self = this;
-            var defer = $.Deferred();
-            var store_id = self.ResUser[0].store_id[0];
-            var date_min = moment().format('YYYY-MM-01');
-            var date_max = moment().add(1, 'month').format('YYYY-MM-01');
-            var fields = ['id','store_id', 'date', 'sale_objetive', 'purchase_limit', 'expense_limit', 'expected_profit'];
-            var domain = [['date', '>=', date_min],['date', '<', date_max],['store_id','=',store_id]];
-            var DashboardObjetive = new model.web.Model('dashboard.objetive');
-            DashboardObjetive.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        getResCurrency: function (id) {
-            var self = this;
-            return _.filter(self.ResCurrency,function (item) {
-                return item.id === id;
-            })
-        
-        },
-
-        /*
-            ACCOUNT INVOICE
-        */
-
-        getTodayAccountInvoice:function() {
-            var self = this;
-            var date = moment().format('YYYY-MM-DD');
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM-DD') === date;
-            }));
-        },
-
-        getThisWeekAccountInvoice:function() {
-            var self = this;
-            var week = moment().week();
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).week() === week & moment(inv.date_invoice).format('YYYY')=== moment().format('YYYY');
-            }));
-        },
-
-        getThisMonthAccountInvoice:function() {
-            var self = this;
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM')=== moment().format('YYYY-MM');
-            }));
-        },
-
-        /* 
-            ACCOUNT INVOICE BY MONTH
-        */
-
-        getMonthAccountInvoice:function(mes) {
-            var self = this;
-            if (mes < 10){
-                var fecha = moment().format('YYYY')+'-'+'0'+mes;    
-            }else{
-                var fecha = moment().format('YYYY')+'-'+mes;    
-            }
-            return _.flatten(_.filter(self.AccountInvoice,function (inv) {
-                return moment(inv.date_invoice).format('YYYY-MM') === fecha;
-            }));
-        },
-
-        /*
-            TODAY
-        */
-
-        showToday: function () {
-            var self = this;
-            var amount = 0;
-            var pos_amount = 0;
-            var invoice_amount = 0;
-            var data = [];
-            var account_invoice = self.getTodayAccountInvoice();
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            if(account_invoice.length > 0){
-                _.each(account_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    data.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_amount = _.reduce(_.map(data, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            amount = invoice_amount;
-            self.today = amount;
-        },
-
-        /*
-            WEEK
-        */
-
-        showThisWeek: function () {
-            var self = this;
-            var amount = 0;
-            var pos_amount = 0;
-            var invoice_amount = 0;
-            var data = [];
-            var account_invoice = self.getThisWeekAccountInvoice();
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            if(account_invoice.length > 0){
-                _.each(account_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    data.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_amount = _.reduce(_.map(data, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            amount = invoice_amount;
-            self.week = amount;
-        },
-
-        /* 
-            MONTH
-        */
-
-        showThisMonth: function () {
-            var self = this;
-            if(self.DashboardObjetive.length > 0){
-                self.objective = self.DashboardObjetive.shift().sale_objetive;    
-            }else{
-                self.objective = 0;    
-            }
-            var pos_amount = 0;
-            var invoice_amount = 0;
-            var amount = 0;
-            var data = [];            
-            var account_invoice = self.getThisMonthAccountInvoice();
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            if(account_invoice.length > 0){
-                _.each(account_invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    data.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                invoice_amount = _.reduce(_.map(data, function (map) {
-                    return map.amount;
-                }), function (memo, num) {
-                    return memo + num;
-                });
-            }
-            amount = invoice_amount;
-            self.month = amount;
-            if(self.objective > 0){ 
-                var percentage = (amount*100)/self.objective;    
-            }else{
-                var percentage = 0;
-            }
-            var chart1 = new ldBar("#circle-saleorder",{
-                'stroke':'#43a047',
-                'stroke-width':'10'
-            });
-            chart1.set(percentage);
-            self.percentage = percentage;
-            self.$el.find('.widget-content').find('a').text(accounting.formatMoney(amount, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator))
-        },
-
-        showMonth: function() {
-            var self = this;
-            var invoice;
-            var title = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
-            var data = [];
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            for (var i = 1; i <= 12; i++) {
-                var array = [];
-                invoice = self.getMonthAccountInvoice(i);
-                 _.each(invoice, function (item) {
-                    var currency = self.getResCurrency(item.currency_id[0]).shift();
-                    array.push({
-                        amount: item.amount_total * (CurrencyBase.rate_silent / currency.rate_silent),
-                    })
-                });
-                
-                var invoice_total = 0;
-                if(array.length > 0){
-                    invoice_total = _.reduce(_.map(array, function (map) {
-                        return map.amount;
-                    }), function (memo, num) {
-                        return memo + num;
-                    });
-                }
-                var total = invoice_total;
-                data.push(total);
-            }
-            self.data = data;
-        },
-
-        /* 
-            MODAL
-        */
-
-        showModal: function (e) {
-            var self = this;
-            self.showThisWeek();
-            self.showToday();
-            self.showMonth();
-            var titleData = [
-                {
-                    title: "Ventas"
-                }
-            ];
-            var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
-            var modal = Qweb.render('WidgetModal', {
-                modalTitle: titleData,
-                objective: accounting.formatMoney(self.objective, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                today: accounting.formatMoney(self.today, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                week: accounting.formatMoney(self.week, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-                month: accounting.formatMoney(self.month, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-            });
-
-            $('.openerp_webclient_container').after(modal);
-            $('.widget-modal').modal()
-            $('.widget-modal').on('hidden.bs.modal', function (e) {
-                self.removeModal(e);
-            })
-
-            var chartX = new ldBar("#myItemModal",{
-                'stroke':'#43a047',
-            });
-            chartX.set(self.percentage);
-
-            self.fetchChart(self.data);
-        },
-
-        removeModal: function (e) {
-            $('.widget-modal').remove();
-            $('.modal-backdrop').remove();
-        },
-
-        /*
-            BUILD A CHART    
-        */
-
-        fetchChart: function (data) {
-            var self = this;
-            var label = ['Ene', 'Feb', 'Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
-            var body = data;
-
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var chart = new Chart($("#prueba"), {
-                type: 'line',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: '#e3f2fd',
-                            borderColor: '#43a047',
-                            borderWidth: 2,
-                            fill: false,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 45,
-                            bottom: 40,
-                            left : 10,
-                            rigth: 10,
-                        }
-                    },
-                    elements: {
-                        line: {
-                            tension: 0.000001
-                        }
-                    },
-                }
-            });
-        },
-
-    });
-}

+ 437 - 0
static/src/lib/circliful.js

@@ -0,0 +1,437 @@
+"use strict";
+
+(function ($) {
+
+    $.fn.circliful = function (options, callback) {
+
+        var settings = $.extend({
+            // These are the defaults.
+            foregroundColor: "#3498DB",
+            backgroundColor: "#ccc",
+            pointColor: "none",
+            fillColor: 'none',
+            foregroundBorderWidth: 15,
+            backgroundBorderWidth: 15,
+            pointSize: 28.5,
+            fontColor: '#aaa',
+            percent: 75,
+            animation: 1,
+            animationStep: 5,
+            icon: 'none',
+            iconSize: '30',
+            iconColor: '#ccc',
+            iconPosition: 'top',
+            iconDecoration: true,
+            target: 0,
+            start: 0,
+            showPercent: 1,
+            percentageTextSize: 22,
+            percentageX: 100,
+            percentageY: 113,
+            textAdditionalCss: '',
+            targetPercent: 0,
+            targetTextSize: 17,
+            targetColor: '#2980B9',
+            text: null,
+            textStyle: null,
+            textColor: '#666',
+            textY: null,
+            textX: null,
+            multiPercentage: 0,
+            percentages: [],
+            multiPercentageLegend: 0,
+            textBelow: false,
+            noPercentageSign: false,
+            replacePercentageByText: null,
+            halfCircle: false,
+            animateInView: false,
+            decimals: 0,
+            alwaysDecimals: false,
+            title: 'Circle Chart',
+            description: '',
+            progressColor: null
+        }, options);
+
+        return this.each(function () {
+            var circleContainer = $(this);
+
+            mergeDataAttributes(settings, circleContainer.data());
+
+            var percent = settings.percent;
+            var iconY = 83;
+            var iconX = 100;
+            var percentageY = settings.percentageY;
+            var percentageX = settings.percentageX;
+            var additionalCss;
+            var elements;
+            var icon;
+            var backgroundBorderWidth = settings.backgroundBorderWidth;
+            var progressColor = settings.progressColor
+
+            if (settings.halfCircle) {
+                if (settings.iconPosition === 'left') {
+                    iconX = 80;
+                    iconY = 100;
+                    percentageX = 117;
+                    percentageY = 100;
+                } else if (settings.halfCircle) {
+                    iconY = 80;
+                    percentageY = 100;
+                }
+            } else {
+                if (settings.iconPosition === 'bottom') {
+                    iconY = 124;
+                    percentageY = 95;
+                } else if (settings.iconPosition === 'left') {
+                    iconX = 80;
+                    iconY = 110;
+                    percentageX = 117;
+                } else if (settings.iconPosition === 'middle') {
+                    if (settings.multiPercentage !== 1) {
+                        if (settings.iconDecoration) {
+                          elements = '<g stroke="' + (settings.backgroundColor !== 'none' ? settings.backgroundColor : '#ccc') + '" ><line x1="133" y1="50" x2="140" y2="40" stroke-width="2"  /></g>';
+                          elements += '<g stroke="' + (settings.backgroundColor !== 'none' ? settings.backgroundColor : '#ccc') + '" ><line x1="140" y1="40" x2="200" y2="40" stroke-width="2"  /></g>';
+                        }
+                        percentageX = 170; // To center the percentage exactly in the center.
+                        percentageY = 35;
+                    }
+                    iconY = 110;
+                } else if (settings.iconPosition === 'right') {
+                    iconX = 120;
+                    iconY = 110;
+                    percentageX = 80;
+                } else if (settings.iconPosition === 'top' && settings.icon !== 'none') {
+                    percentageY = 120;
+                }
+            }
+
+            if (settings.targetPercent > 0 && settings.halfCircle !== true) {
+                percentageY = 95;
+                elements = '<g stroke="' + (settings.backgroundColor !== 'none' ? settings.backgroundColor : '#ccc') + '" ><line x1="75" y1="101" x2="125" y2="101" stroke-width="1"  /></g>';
+                elements += '<text text-anchor="middle" x="' + percentageX + '" y="120" style="font-size: ' + settings.targetTextSize + 'px;" fill="' + settings.targetColor + '">' + settings.targetPercent + (settings.noPercentageSign && settings.replacePercentageByText === null ? '' : '%') + '</text>';
+                elements += '<circle cx="100" cy="100" r="69" fill="none" stroke="' + settings.backgroundColor + '" stroke-width="3" stroke-dasharray="450" transform="rotate(-90,100,100)" />';
+                elements += '<circle cx="100" cy="100" r="69" fill="none" stroke="' + settings.targetColor + '" stroke-width="3" stroke-dasharray="' + (435 / 100 * settings.targetPercent) + ', 20000" transform="rotate(-90,100,100)" />';
+            }
+
+            if (settings.text !== null) {
+                if (settings.halfCircle) {
+                    if (settings.textBelow) {
+                        elements += '<text text-anchor="middle" x="' + (settings.textX !== null ? settings.textX : '100') + '" y="' + (settings.textY !== null ? settings.textY : '64%') + '" style="' + settings.textStyle + '" fill="' + settings.textColor + '">' + settings.text + '</text>';
+                    }
+                    else {
+                        elements += '<text text-anchor="middle" x="' + (settings.textX !== null ? settings.textX : '100' ) + '" y="' + (settings.textY !== null ? settings.textY : '115') + '" style="' + settings.textStyle + '" fill="' + settings.textColor + '">' + settings.text + '</text>';
+                    }
+                } else {
+                    if (settings.textBelow) {
+                        elements += '<text text-anchor="middle" x="' + (settings.textX !== null ? settings.textX : '100' ) + '" y="' + (settings.textY !== null ? settings.textY : '99%') + '" style="' + settings.textStyle + '" fill="' + settings.textColor + '">' + settings.text + '</text>';
+                    }
+                    else {
+                        elements += '<text text-anchor="middle" x="' + (settings.textX !== null ? settings.textX : '100' ) + '" y="' + (settings.textY !== null ? settings.textY : '115') + '" style="' + settings.textStyle + '" fill="' + settings.textColor + '">' + settings.text + '</text>';
+                    }
+                }
+            }
+
+            if (settings.icon !== 'none') {
+                icon = '<text text-anchor="middle" x="' + iconX + '" y="' + iconY + '" class="icon" style="font-size: ' + settings.iconSize + 'px" fill="' + settings.iconColor + '">&#x' + settings.icon + '</text>';
+            }
+
+            if (settings.halfCircle) {
+                var rotate = 'transform="rotate(-180,100,100)"';
+                circleContainer
+                    .addClass('svg-container')
+                    .append(
+                        $('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 194 186" class="circliful">' +
+                            (typeof elements !== 'undefined' ? elements : '') +
+                            '<clipPath id="cut-off-bottom"> <rect x="100" y="0" width="100" height="200" /> </clipPath>' +
+                            '<circle cx="100" cy="100" r="57" class="border" fill="' + settings.fillColor + '" stroke="' + settings.backgroundColor + '" stroke-width="' + backgroundBorderWidth + '" stroke-dasharray="360" clip-path="url(#cut-off-bottom)" transform="rotate(-90,100,100)" />' +
+                            '<circle class="circle" cx="100" cy="100" r="57" class="border" fill="none" stroke="' + settings.foregroundColor + '" stroke-width="' + settings.foregroundBorderWidth + '" stroke-dasharray="0,20000" ' + rotate + ' />' +
+                            '<circle cx="100" cy="100" r="' + settings.pointSize + '" fill="' + settings.pointColor + '" clip-path="url(#cut-off-bottom)" transform="rotate(-90,100,100)" />' +
+                            icon +
+                            '<text class="timer" text-anchor="middle" x="' + percentageX + '" y="' + percentageY + '" style="font-size: ' + settings.percentageTextSize + 'px; ' + additionalCss + ';' + settings.textAdditionalCss + '" fill="' + settings.fontColor + '"><tspan class="number">' + (settings.replacePercentageByText === null ? 0 : settings.replacePercentageByText) + '</tspan><tspan class="percent">' + (settings.noPercentageSign || settings.replacePercentageByText !== null ? '' : '%') + '</tspan></text>')
+                    );
+            } else {
+                drawCircles();
+            }
+
+            var circle = circleContainer.find('.circle');
+            var myTimer = circleContainer.find('.timer');
+            var interval = 30;
+            var angle = 0;
+            var angleIncrement = settings.animationStep;
+            var last = 0;
+            var summary = 0;
+            var oneStep = 0;
+            var text = percent;
+            var calculateFill = (360 / 100 * percent);
+
+            if (settings.halfCircle) {
+                calculateFill = (360 / 100 * percent) / 2;
+            }
+
+            if (settings.replacePercentageByText !== null) {
+                text = settings.replacePercentageByText;
+            }
+
+            if (settings.start > 0 && settings.target > 0) {
+                percent = settings.start / (settings.target / 100);
+                oneStep = settings.target / 100;
+            }
+
+            if (settings.animation === 1) {
+                if (settings.animateInView) {
+                    $(window).scroll(function () {
+                        checkAnimation();
+                    });
+                } else {
+                    animate();
+                }
+            } else {
+                if (settings.multiPercentage !== 1) {
+                    circle
+                        .attr("stroke-dasharray", calculateFill + ", 20000");
+
+                    if (settings.showPercent === 1) {
+                        myTimer
+                            .find('.number')
+                            .text(text);
+                    } else {
+                        myTimer
+                            .find('.number')
+                            .text(settings.target);
+                        myTimer
+                            .find('.percent')
+                            .text('');
+                    }
+                } else {
+                    if (settings.replacePercentageByText !== null) {
+                        myTimer
+                            .find('.number')
+                            .text(settings.replacePercentageByText);
+                        myTimer
+                            .find('.percent')
+                            .text('');
+                    }
+                }
+            }
+
+            function animate() {
+                var currentCircle = circle;
+                var currentCalculateFill = calculateFill;
+
+                if (settings.multiPercentage === 1) {
+                    var index;
+                    var percentages = settings.percentages;
+                    var circleRadius = 360;
+                    for (index = 0; index < percentages.length; ++index) {
+                        percent = percentages[index].percent;
+                        currentCalculateFill = (circleRadius / 100 * percent);
+                        currentCircle = circleContainer.find('#circle' + (index + 1));
+
+                        if (index > 0) {
+                            circleRadius = circleRadius + 62.5;
+                            currentCalculateFill = (circleRadius / 100 * percent);
+                        }
+
+                        animateCircle(currentCircle, currentCalculateFill, circleRadius, percent);
+                    }
+                } else {
+                    animateCircle(currentCircle, currentCalculateFill, 360, percent);
+                }
+            }
+
+            function animateCircle(currentCircle, currentCalculateFill, circleRadius, percent) {
+                var timer = window.setInterval(function () {
+                    if ((angle) >= currentCalculateFill) {
+                        window.clearInterval(timer);
+                        last = 1;
+                        if (typeof callback === 'function') {
+                            callback.call(this);
+                        }
+                    } else {
+                        angle += angleIncrement;
+                        summary += oneStep;
+                    }
+                    if (settings.halfCircle) {
+                        if (angle * 2 / (circleRadius / 100) >= percent && last === 1) {
+                            angle = ((circleRadius / 100) * percent) / 2
+                        }
+                    } else {
+                        if (angle / (circleRadius / 100) >= percent && last === 1) {
+                            angle = (circleRadius / 100) * percent;
+                        }
+                    }
+
+                    if (summary > settings.target && last === 1) {
+                        summary = settings.target;
+                    }
+
+                    if (settings.replacePercentageByText === null) {
+                        if (settings.halfCircle) {
+                            text = parseFloat((100 * angle / circleRadius) * 2);
+                        } else {
+                            text = parseFloat((100 * angle / circleRadius));
+                        }
+                        text = Math.floor(text);
+                        if (!settings.alwaysDecimals && (percent === 0 || (percent > 1 && last !== 1))) {
+                            text = parseInt(text);
+                        }
+                    }
+
+                    currentCircle
+                        .attr("stroke-dasharray", angle + ", 20000");
+
+                    if (settings.multiPercentage !== 1) {
+                        if (settings.showPercent === 1) {
+                            myTimer
+                                .find('.number')
+                                .text(text);
+                        } else {
+
+                            myTimer
+                                .find('.number')
+                                .text(summary);
+                            myTimer
+                                .find('.percent')
+                                .text('');
+                        }
+                    } else {
+                        myTimer
+                            .find('.number')
+                            .text('');
+                        myTimer
+                            .find('.percent')
+                            .text('');
+                    }
+
+                    if (progressColor !== null) {
+                        $.each(progressColor, function (key, color) {
+                            if (settings.halfCircle) {
+                                key /= 2
+                            }
+                            if (angle >= key * (circleRadius / 100)) {
+                                currentCircle.css({
+                                    stroke: color,
+                                    transition: 'stroke 0.1s linear'
+                                });
+                            }
+                        });
+                    }
+                }.bind(currentCircle), interval);
+            }
+
+            function isElementInViewport() {
+                // Get the scroll position of the page.
+                var scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') !== -1) ? 'body' : 'html');
+                var viewportTop = $(scrollElem).scrollTop();
+                var viewportBottom = viewportTop + $(window).height();
+
+                // Get the position of the element on the page.
+                var elemTop = Math.round(circle.offset().top);
+                var elemBottom = elemTop + circle.height();
+
+                return ((elemTop < viewportBottom) && (elemBottom > viewportTop));
+            }
+
+            function checkAnimation() {
+                // If the animation has already been started
+                if (circle.hasClass('start')) return;
+
+                if (isElementInViewport(circle)) {
+                    // Start the animation
+                    circle.addClass('start');
+                    setTimeout(animate, 250)
+                }
+            }
+
+            function mergeDataAttributes(settings, dataAttributes) {
+                $.each(settings, function (key, value) {
+                    if (key.toLowerCase() in dataAttributes) {
+                        settings[key] = dataAttributes[key.toLowerCase()];
+                    }
+                });
+            }
+
+            /**
+             * Draws the initial circles before animate gets called
+             */
+            function drawCircles() {
+                if (settings.multiPercentage === 1) {
+                    var index, calculateFillMulti, percent, color, circles;
+                    var percentages = settings.percentages;
+                    var radius = 47;
+                    var circleRadius = 360;
+                    var rotate = -90;
+                    for (index = 0; index < percentages.length; ++index) {
+                        percent = percentages[index].percent;
+                        color = percentages[index].color;
+                        calculateFillMulti = (circleRadius / 100 * percent);
+                        if (index > 0) {
+                            circleRadius = circleRadius + 62.5;
+                            calculateFillMulti = (circleRadius / 100 * percent);
+                        }
+                        radius += 10;
+                        circles += '<circle cx="100" cy="100" r="' + radius + '" class="border" fill="' + settings.fillColor + '" stroke="' + settings.backgroundColor + '" stroke-width="' + backgroundBorderWidth + '" stroke-dasharray="' + circleRadius + '" transform="rotate(' + rotate + ',100,100)" />' +
+                            '<circle class="circle" id="circle' + (index + 1) + '" data-percent="' + percent + '" cx="100" cy="100" r="' + radius + '" class="border" fill="none" stroke="' + color + '" stroke-width="' + settings.foregroundBorderWidth + '" stroke-dasharray="' + calculateFillMulti + ',20000" transform="rotate(' + rotate + ',100,100)" />';
+                    }
+
+                    circleContainer
+                        .addClass('svg-container')
+                        .append(
+                            $('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 194 186" class="circliful">' +
+                                (typeof elements !== 'undefined' ? elements : '') +
+                                circles +
+                                icon +
+                                '<text class="timer" text-anchor="middle" x="' + percentageX + '" y="' + percentageY + '" style="font-size: ' + settings.percentageTextSize + 'px; ' + additionalCss + ';' + settings.textAdditionalCss + '" fill="' + settings.fontColor + '">' +
+                                '<tspan class="number">' + (settings.replacePercentageByText === null ? 0 : settings.replacePercentageByText) + '</tspan>' +
+                                '<tspan class="percent">' + (settings.noPercentageSign || settings.replacePercentageByText !== null ? '' : '%') + '</tspan>' +
+                                '</text>')
+                        );
+
+                    if (settings.multiPercentageLegend === 1) {
+                        showLegend();
+                    }
+                } else {
+                    circleContainer
+                        .addClass('svg-container')
+                        .append(
+                            $('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 194 186" class="circliful">' +
+                                (typeof elements !== 'undefined' ? elements : '') +
+                                '<circle cx="100" cy="100" r="57" class="border" fill="' + settings.fillColor + '" stroke="' + settings.backgroundColor + '" stroke-width="' + backgroundBorderWidth + '" stroke-dasharray="360" transform="rotate(-90,100,100)" />' +
+                                '<circle class="circle" cx="100" cy="100" r="57" class="border" fill="none" stroke="' + settings.foregroundColor + '" stroke-width="' + settings.foregroundBorderWidth + '" stroke-dasharray="0,20000" transform="rotate(-90,100,100)" />' +
+                                '<circle cx="100" cy="100" r="' + settings.pointSize + '" fill="' + settings.pointColor + '" />' +
+                                icon +
+                                '<text class="timer" text-anchor="middle" x="' + percentageX + '" y="' + percentageY + '" style="font-size: ' + settings.percentageTextSize + 'px; ' + additionalCss + ';' + settings.textAdditionalCss + '" fill="' + settings.fontColor + '">' +
+                                '<tspan class="number">' + (settings.replacePercentageByText === null ? 0 : settings.replacePercentageByText) + '</tspan>' +
+                                '<tspan class="percent">' + (settings.noPercentageSign || settings.replacePercentageByText !== null ? '' : '%') + '</tspan>' +
+                                '</text>')
+                        );
+                }
+            }
+
+            /**
+             * Show the legend only for multi percentage circles
+             */
+            function showLegend() {
+                var height = circleContainer.height();
+                var width = circleContainer.width();
+                var percentages = settings.percentages;
+                var index;
+                var lines = '';
+                for (index = 0; index < percentages.length; ++index) {
+                    var title = percentages[index].title;
+                    var color = percentages[index].color;
+                    var percent = percentages[index].percent;
+
+                    lines += '<div><span class="color-box" style="background: ' + color + '"></span>' + title + ', ' + percent + '%</div>';
+                }
+
+                circleContainer.append(
+                    $('<div/>')
+                        .append(lines)
+                        .attr('style', 'position:absolute;top:' + height / 3 + 'px;left:' + (width + 20) + 'px')
+                        .attr('class', 'legend-line')
+                );
+            }
+        });
+    }
+}(jQuery));

+ 0 - 0
static/src/xml/widgets/chart_ingreso_egreso.xml → static/src/xml/charts/chart_ingreso_egreso.xml


+ 1 - 1
static/src/xml/widgets/chart_pos_order_customer.xml → static/src/xml/charts/chart_ranking_customer.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <template xml:space="preserve">
-    <t t-name="ChartPosOrderCustomer">
+    <t t-name="ChartRankingCustomer">
         <t t-call="WidgetReportingBaseTemplate">
             <div class="widget-content">
                 <div class="chart-container">

+ 1 - 1
static/src/xml/widgets/chart_pos_order_product.xml → static/src/xml/charts/chart_ranking_product.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <template xml:space="preserve">
-    <t t-name="ChartPosOrderProduct">
+    <t t-name="ChartRankingProduct">
         <t t-call="WidgetReportingBaseTemplate">
             <div class="widget-content">
                 <div class="chart-container">

+ 1 - 1
static/src/xml/widgets/chart_pos_order_salesman.xml → static/src/xml/charts/chart_ranking_salesman.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <template xml:space="preserve">
-    <t t-name="ChartPosOrderSalesman">
+    <t t-name="ChartRankingSalesman">
         <t t-call="WidgetReportingBaseTemplate">
             <div class="widget-content">
                 <div class="chart-container">

+ 0 - 0
static/src/xml/widgets/chart_sale_by_store.xml → static/src/xml/charts/chart_sale_by_store.xml


+ 0 - 39
static/src/xml/widgets/chart_invoice.xml

@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<template xml:space="preserve">
-    <t t-name="ChartInvoice">
-        <t t-call="WidgetReportingBaseTemplate">
-            <h2  class="widget-title">
-                <div class="row">
-                    <div class="col-xs-6">
-                        <i class="fa fa-bar-chart" aria-hidden="true"></i>
-                        <span>Ventas</span> 
-                    </div>
-                    <div class="col-xs-6">
-                        <div class="col-xs-6 col-xs-offset-10">
-                            <div class="btn-group btn-group-xs">
-                                <a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                <span class="caret"></span>
-                                <span class="sr-only">Toggle Dropdown</span>
-                                </a>
-                                <ul class="dropdown-menu dropdown-menu-right">
-                                    <li><a class="days">15 dias</a></li>
-                                    <li><a class="month">Meses</a></li>
-                                    <li role="separator" class="divider"></li>
-                                    <li><a class="week">Esta Semana</a></li>
-                                </ul>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </h2>
-            <div class="widget-content">
-                <div class="container">
-                    <canvas></canvas>    
-                </div>
-            </div>
-            <div class="widget-content widget-loading">
-                <i class='fa fa-cog fa-spin fa-3x fa-fw'></i>
-            </div>
-        </t>
-    </t>
-</template>

+ 0 - 40
static/src/xml/widgets/chart_pos_order.xml

@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<template xml:space="preserve">
-    <t t-name="ChartPosOrder">
-        <t t-call="WidgetReportingBaseTemplate">
-            <h2  class="widget-title">
-                <div class="row">
-                    <div class="col-xs-6">
-                        <i class="fa fa-bar-chart" aria-hidden="true"></i>
-                        <span>Ventas</span> 
-                    </div>
-                    <div class="col-xs-6">
-                        <div class="col-xs-6 col-xs-offset-10">
-                            <div class="btn-group btn-group-xs">
-                                <a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                <span class="caret"></span>
-                                <span class="sr-only">Toggle Dropdown</span>
-                                </a>
-                                <ul class="dropdown-menu dropdown-menu-right">
-                                    <li><a class="days">15 dias</a></li>
-                                    <li><a class="month">Meses</a></li>
-                                    <li role="separator" class="divider"></li>
-                                    <li><a class="week">Esta Semana</a></li>
-                                </ul>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </h2>
-            <div class="widget-content">
-                <div class="container">
-                    <canvas></canvas>    
-                </div>
-            </div>
-            <div class="widget-content widget-loading">
-                <i class='fa fa-cog fa-spin fa-3x fa-fw'></i>
-            </div>
-        </t>
-    </t>
-</template>

+ 0 - 40
static/src/xml/widgets/chart_purchase_expense.xml

@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<template xml:space="preserve">
-    <t t-name="ChartPurchaseExpense">
-        <t t-call="WidgetReportingBaseTemplate">
-            <h2  class="widget-title">
-                <div class="row">
-                    <div class="col-xs-6">
-                        <i class="fa fa-bar-chart" aria-hidden="true"></i>
-                        <span>Compras y Gastos</span> 
-                    </div>
-                    <div class="col-xs-6">
-                        <div class="col-xs-6 col-xs-offset-10">
-                            <div class="btn-group btn-group-xs">
-                                <a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                <span class="caret"></span>
-                                <span class="sr-only">Toggle Dropdown</span>
-                                </a>
-                                <ul class="dropdown-menu dropdown-menu-right">
-                                    <li><a class="days">15 dias</a></li>
-                                    <li><a class="month">Meses</a></li>
-                                    <li role="separator" class="divider"></li>
-                                    <li><a class="week">Esta Semana</a></li>
-                                </ul>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </h2>
-            <div class="widget-content">
-                <div class="container">
-                    <canvas></canvas>    
-                </div>
-            </div>
-            <div class="widget-content widget-loading">
-                <i class='fa fa-cog fa-spin fa-3x fa-fw'></i>
-            </div>
-        </t>
-    </t>
-</template>

+ 0 - 14
static/src/xml/widgets/chart_sale_order_customer.xml

@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<template xml:space="preserve">
-    <t t-name="ChartSaleOrderCustomer">
-        <t t-call="WidgetReportingBaseTemplate">
-            <div class="widget-content">
-                <div class="chart-container">
-                    <h3 class="text-center">Ranking de Clientes</h3>
-                    <canvas></canvas>    
-                </div>
-            </div>
-        </t>
-    </t>
-</template>

+ 0 - 13
static/src/xml/widgets/chart_sale_order_product.xml

@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<template xml:space="preserve">
-    <t t-name="ChartSaleOrderProduct">
-        <t t-call="WidgetReportingBaseTemplate">
-           <div class="widget-content">
-                <div class="chart-container">
-                    <h3 class="text-center">Ranking de Productos</h3>
-                    <canvas></canvas>    
-                </div>
-            </div>
-        </t>
-    </t>
-</template>

+ 0 - 14
static/src/xml/widgets/chart_sale_order_salesman.xml

@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<template xml:space="preserve">
-    <t t-name="ChartSaleOrderSalesman">
-        <t t-call="WidgetReportingBaseTemplate">
-            <div class="widget-content">
-                <div class="chart-container">
-                    <h3 class="text-center">Vendedores</h3>
-                    <canvas></canvas>    
-                </div>
-            </div>
-        </t>
-    </t>
-</template>

+ 1 - 4
static/src/xml/widgets/eiru_dashboard_modal.xml

@@ -35,7 +35,7 @@
                                         <td>
                                             <t t-set="monto" t-value="field_value.amount_residual"/>
                                             <t t-js="ctx">
-                                                ctx.monto = accounting.formatNumber(ctx.monto,0,'.',',');
+                                                ctx.monto = accounting.formatNumber(ctx.monto,2,'.',',');
                                             </t>
                                             <t t-esc="monto"/>
                                         </td>
@@ -44,9 +44,6 @@
                             </table>
                         </div>
                     </div>
-                    <div class="modal-footer">
-                        <!-- <button type="button" class="btn btn-default " data-dismiss="modal">Cerrar</button> -->
-                    </div>
                 </div> 
             </div>
         </div>

+ 2 - 4
static/src/xml/widgets/widget_balance.xml

@@ -8,13 +8,11 @@
                         <div class="hidden-xs hidden-sm hidden-md col-lg-4 block-left">
                             <div 
                                 id="circle-balance" 
-                                data-preset="circle" 
-                                class="ldBar label-center" 
-                                style="width:130px; height:130px; font-family:Arial; font-size: 2.3em; margin:auto"
+                                style="width:150px; height:150px;margin:auto"
                             ></div>
                         </div>
                         <div class="col-xs-12 col-md-12 col-lg-8 text-right">
-                            <br/><br/>
+                            <br/><br/><br/>
                             <h4>Balance</h4>
                             <a class="number"></a>   
                         </div>    

+ 2 - 4
static/src/xml/widgets/widget_expense.xml

@@ -8,13 +8,11 @@
                         <div class="hidden-xs hidden-sm hidden-md col-lg-4 block-left">
                             <div 
                                 id="circle-expense" 
-                                data-preset="circle" 
-                                class="ldBar label-center circle-chart" 
-                                style="width:130px; height:130px; font-family:Arial; font-size: 2.3em; margin:auto"
+                                style="width:150px; height:150px; margin:auto"
                             ></div>
                         </div>
                         <div class="col-xs-12 col-md-12 col-lg-8 text-right">
-                            <br/><br/>
+                            <br/><br/><br/>
                             <h4>Gastos</h4>
                             <a class="number"></a>    
                         </div>    

+ 4 - 1
static/src/xml/widgets/widget_modal.xml

@@ -28,7 +28,10 @@
                         <h3>Este Mes</h3>
                         <h2><t t-esc="month"/></h2>    
                     </div>
-                    <canvas id="prueba" class="modal-chart" height="100"></canvas>
+                    <div class="container" style="padding:20px;">
+                        <canvas id="prueba" class="modal-chart" height="100"></canvas>    
+                    </div>
+                    
                 </div> 
             </div>
         </div>

+ 2 - 4
static/src/xml/widgets/widget_purchase.xml

@@ -8,13 +8,11 @@
                         <div class="hidden-xs hidden-sm hidden-md col-lg-4 block-left">
                             <div 
                                 id="circle-purchase" 
-                                data-preset="circle" 
-                                class="ldBar label-center circle-chart" 
-                                style="width:130px; height:130px;font-family:Arial; font-size: 2.3em; margin:auto"
+                                style="width:150px; height:150px;margin:auto"
                             ></div>
                         </div>
                         <div class="col-xs-12 col-md-12 col-lg-8 text-right">
-                            <br/><br/>
+                            <br/><br/><br/>
                             <h4>Compras</h4>
                             <a class="number"></a>    
                         </div>    

+ 5 - 7
static/src/xml/widgets/widget_pos_order.xml → static/src/xml/widgets/widget_sale.xml

@@ -1,20 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <template xml:space="preserve">
-    <t t-name="WidgetPosOrder">
+    <t t-name="WidgetSale">
         <div>
             <div class="grid-stack-item-content reporting-dashboard green">
                 <div class="widget-content">
                     <div class="row">
                         <div class="hidden-xs hidden-sm hidden-md col-lg-4 block-left">
                             <div 
-                                id="circle-posorder" 
-                                data-preset="circle" 
-                                class="ldBar label-center circle-chart" 
-                                style="width:130px; height:130px; font-family:Arial; font-size: 2.3em; margin:auto"
+                                id="circle-posorder"  
+                                style="width:150px; height:150px;margin:auto"
                             ></div>
                         </div>
-                        <div class="col-xs-12 col-md-12 col-lg-8 text-right">
-                            <br/><br/>
+                        <div class="col-xs-12 col-md-12 col-lg-8 text-right" >
+                            <br/><br/><br/>
                             <h4>Ventas</h4>
                             <a class="number"></a>    
                         </div>    

+ 31 - 18
templates.xml

@@ -4,44 +4,57 @@
         <!-- Templates -->
         <template id="eiru_reporting_dashboard_assets" inherit_id="eiru_assets.assets">
             <xpath expr="." position="inside">
+                
                 <!-- Dashboard Style -->
                 <link rel="stylesheet" href="/eiru_reporting_dashboard/static/src/css/dashboard.css" />
                 <link rel="stylesheet" href="/eiru_reporting_dashboard/static/src/css/configuration.css" />
-                <link rel="stylesheet" href="/eiru_reporting_dashboard/static/src/css/loading-bar.css" />
+                <link rel="stylesheet" href="/eiru_reporting_dashboard/static/src/css/circliful.css" />
 
                 <!-- Dashboard Widget Base -->
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widget_base.js" />
 
                 <!-- LIB -->
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/lib/jquery.timeago.es.js" />
-                <!-- <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/lib/moment-timezone.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/lib/timezones.js" /> -->
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/lib/loading-bar.js"/>
+
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/lib/circliful.js"/>
                 
                 <!-- user -->
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/user.js" />
 
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_invoice.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_pos_order_customer.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_pos_order_product.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_pos_order_salesman.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_pos_order.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_sale_by_store.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_purchase_expense.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_pos_order.js" />
+
+                <!--  
+                    WIDGETS
+                -->
+
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_sale.js"/>
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_purchase.js" />
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_expense.js" />
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_balance.js" />
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_cash.js" />
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_bank.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_ingreso_egreso.js" />
+                
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_account_receivable.js" />
+
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_account_to_pay.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_sale_order.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/widget_balance_sale.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_sale_order_customer.js" />
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_sale_order_product.js"/>
-                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/widgets/chart_sale_order_salesman.js"/>
+
+                <!--  
+                    CHARTS
+                -->
+
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/charts/chart_ranking_customer.js" />
+
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/charts/chart_ranking_product.js" />
+                
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/charts/chart_ranking_salesman.js" />
+                
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/charts/chart_sale_by_store.js" />
+
+                <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/charts/chart_ingreso_egreso.js" />
 
                 <!-- Dashboard Main  -->
                 <script type="text/javascript" src="/eiru_reporting_dashboard/static/src/js/dashboard.js" />