diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py index dca371dfc4baa439ca8a8fe81c0eb10f9a54a8e4..9ce5408dad15e43c0f093385bdff4f7ad33c77a8 100644 --- a/models/lefilament_tdb.py +++ b/models/lefilament_tdb.py @@ -104,6 +104,8 @@ class LeFilamentTdb(models.Model): 'facture': 0, 'commandes': 0, 'pipe': 0, + 'pipe_win': 0, + 'pipe_to_win': 0, 'tresorerie': 0, 'entree': 0, 'sortie': 0, @@ -118,6 +120,8 @@ class LeFilamentTdb(models.Model): (select sum(amount_untaxed) from account_invoice where state!='draft' and type='out_invoice' and date >= date_trunc('year', current_date) ) as facture, (select sum(residual_company_signed) from account_invoice where state!='draft' and type='out_invoice' ) as a_encaisser, (select sum(planned_revenue*probability/100) from crm_lead where active=True) as pipe, + (select sum(planned_revenue*probability/100) from crm_lead where active=True and probability=100) as pipe_win, + (select sum(planned_revenue*probability/100) from crm_lead where active=True and probability!=100) as pipe_to_win, (select sum(amount) from account_bank_statement_line ) as tresorerie, (select sum(amount) from account_bank_statement_line where amount > 0 and date >= date_trunc('year', current_date) ) as entree, (select sum(amount) from account_bank_statement_line where amount < 0 and date >= date_trunc('year', current_date) ) as sortie, @@ -135,6 +139,8 @@ class LeFilamentTdb(models.Model): res['facture'] =+ datas[0]['facture'] res['a_encaisser'] =+ datas[0]['a_encaisser'] res['pipe'] =+ datas[0]['pipe'] + res['pipe_win'] =+ datas[0]['pipe_win'] + res['pipe_to_win'] =+ datas[0]['pipe_to_win'] res['tresorerie'] =+ datas[0]['tresorerie'] res['entree'] =+ datas[0]['entree'] res['sortie'] =+ datas[0]['sortie'] diff --git a/static/src/css/lefilament_tdb.css b/static/src/css/lefilament_tdb.css index d40e13c12315e9be4526da3fad1f0f1d05dcd4e9..31b50205925337504aaf19bd135764f2d2db83d0 100644 --- a/static/src/css/lefilament_tdb.css +++ b/static/src/css/lefilament_tdb.css @@ -31,6 +31,7 @@ .yeardashboard { background-color: #F7F7F7; padding: 20px; min-height: 100%; } .yeardashboard h3 { margin: 10px 15px; font-size: 20px; font-weight: 400; border-bottom: 1px solid #ddd; color: #5E6975; } .card { background-color: #fff; color: #73879C; padding: 20px; margin: 10px 0; } +.card a { color: inherit; } .card-half { float: left; width: 50%; } .card-header { margin: 0!important; } .card-number { font-size: 30px; font-weight: 300; margin: 0!important; font-family: "Helvetica Neue", Helvetica, "Open Sans", Arial, sans-serif; } diff --git a/static/src/js/dashboard_year.js b/static/src/js/dashboard_year.js index efe1734c2f9cd16e941117c83d5b21d9777356bb..57d862aaaefb5cd6d4598aac1f85b6ca15919e68 100644 --- a/static/src/js/dashboard_year.js +++ b/static/src/js/dashboard_year.js @@ -15,10 +15,15 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { template: 'YearDashboard', events: { - 'click .card': function() { this.mychart.reflow(); }, + 'click .card': function() { + this.mychart.reflow(); + }, 'click #facture_non_encaisse': function() { this.facture(); }, + 'click #commandes': function() { + this.commandes(); + }, }, init: function() { @@ -42,7 +47,8 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { }, start: function() { - this.render_chart(); + // session.on("request", this, this.render_chart); + return this.render_chart(); }, render_chart: function(chart) { @@ -50,63 +56,18 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var pfact = (this.values.facture / this.values.target * 100).toFixed(0); var pcomm = (this.values.commandes / this.values.target * 100).toFixed(0); - var ppipe = (this.values.pipe / this.values.target * 100).toFixed(0); - var ptarg = 100-pfact-pcomm-ppipe; + var ppipe_win = (this.values.pipe_win / this.values.target * 100).toFixed(0); + var ppipe_to_win = (this.values.pipe_to_win / this.values.target * 100).toFixed(0); + var ptarg = 100-pfact-pcomm-ppipe_win-ppipe_to_win; var pfact2 = (this.values.facture); var pcomm2 = (this.values.commandes); - var ppipe2 = (this.values.pipe); - var ptarg2 = this.values.target -pfact2-pcomm2-ppipe2; - - // ctx = this.$el.find('#progressbar')[0]; - // this.chart = this.$el.find('#myChart')[0].getContext('2d'); - - // var bar = new ProgressBar.Circle(ctx, { - // color: '#43B160', - // easing: 'easeInOut', - // strokeWidth: 5, - // trailWidth: 1, - // step: function(state, circle) { - // value = self.progress*100 - // circle.setText( - // '<span class="ca_target">'+ - // self.values.target.toLocaleString('fr', { maximumFractionDigits: 0 }) + ' € </span><br />' - // +'facturé '+ pfact + ' %<br />' - // +'commandes '+ pcomm + ' %<br />' - // +'pipe '+ ppipe + ' %' - // ); - // }, - // }); - // bar.text.style.fontFamily = '"Helvetica Neue", Helvetica, sans-serif'; - // bar.text.style.fontSize = '12px'; - // bar.text.style.color = '#73879C'; - // bar.text.style.textAlign = 'center'; - // bar.animate(self.progress); - - // var pieData = { - // datasets: [{ - // label: '% C.A', - // data: [pfact, pcomm, ppipe, ptarg], - // backgroundColor: ['#43B160', '#EDA35A', '#ED6A5A', '#f0f0f0'], - // borderColor: ['#43B160', '#EDA35A', '#ED6A5A', '#fff'], - // borderWidth: 2, - // }], - // labels: [' Facturé ', ' Commandes ', " Pipe ", " To Do "] - // }; - - // var myDoughnutChart = new Chart( this.chart, { - // type: 'doughnut', - // data: pieData, - // options: { - // cutoutPercentage: 90, - // responsive: true, - // legend: { display: false, }, - // tooltips: { backgroundColor: "rgba(255,255,255,0.8)", bodyFontSize: 14, bodyFontColor: '#73879C', bodyFontStyle: '300',xPadding: 10, yPadding: 10, displayColors: false, }, - // } - // }); + var ppipe2_win = (this.values.pipe_win); + var ppipe2_to_win = (this.values.pipe_to_win); + var ptarg2 = this.values.target -pfact2-pcomm2-ppipe2_to_win-ppipe2_win; hchart = this.$el.find('#hchart')[0]; - Highcharts.setOptions({ colors: ['#8ED8A2', '#F6CCA2', '#F6ACA2', '#f8f8f8'], }); + Highcharts.setOptions({ colors: ['#8ED8A2', '#F6DCA2', '#F6CCA2', '#F6ACA2', '#eee'], }); this.mychart = new Highcharts.chart({ chart: { @@ -119,11 +80,12 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { self.values.target.toLocaleString('fr', { maximumFractionDigits: 0 }) + ' € </span><br />' +'facturé '+ pfact + ' %<br />' +'commandes '+ pcomm + ' %<br />' - +'pipe '+ ppipe + ' %', + +'gagné '+ ppipe_win + ' %<br />' + +'pipe '+ ppipe_to_win + ' %', align: 'center', verticalAlign: 'middle', style: { 'color': '#73879C', 'font-size': '11px' }, - y: -3, + y: -20, }, plotOptions: { pie: { @@ -153,11 +115,13 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { series: [{ type: 'pie', innerSize: '85%', - data: [ ['Facturé', pfact2], ['Commandes', pcomm2], ['Pipe', ppipe2], ['To Do', ptarg2], ], + data: [ ['Facturé', pfact2], ['Commandes', pcomm2], ['Gagné', ppipe2_win], ['Pipe', ppipe2_to_win], ['To Do', ptarg2], ], slicedOffset: 0, }], }); + + this.mychart.reflow(); }, render_monetary: function(value) { @@ -192,6 +156,27 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { console.log(context); console.log(action); + this.do_action(action); + }, + commandes: function() { + var self = this; + var context = { 'user_id': this.session.uid, } + + var action = ({ + type: 'ir.actions.act_window', + res_model: 'sale.order', + view_type: 'form', + view_mode: 'tree,form', + views: [[false, 'list'], [false, 'form']], + domain: [['invoice_status','=','to invoice']], + target:'current', + name: 'Commandes en cours', + context: context + }) + + console.log(context); + console.log(action); + this.do_action(action); }, }); diff --git a/static/src/xml/lefilament_tdb.xml b/static/src/xml/lefilament_tdb.xml index a6dcea6ed8c3a0a4dc7cc69e122a39c828bb4398..889151ae1f82442eca751a9af08d0c4e53769217 100644 --- a/static/src/xml/lefilament_tdb.xml +++ b/static/src/xml/lefilament_tdb.xml @@ -95,7 +95,9 @@ <div class="card"> <p class="card-header">Commandes en cours</p> <p class="card-number"> - <t t-esc="widget.render_monetary(widget.values.commandes)"></t> + <a id="commandes"> + <t t-esc="widget.render_monetary(widget.values.commandes)"></t> + </a> </p> </div> </div> @@ -111,7 +113,7 @@ <div class="card"> <p class="card-header">Facturé non encaissé</p> <p class="card-number"> - <a id="facture_non_encaisse" type="action"> + <a id="facture_non_encaisse"> <t t-esc="widget.render_monetary(widget.values.a_encaisser)"></t> </a> </p> diff --git a/views/assets.xml b/views/assets.xml index dcddddb23e864e240fcc6617206d4a53e0a4c52a..8b412281788b2d9b8db652a974e5b925743084f0 100644 --- a/views/assets.xml +++ b/views/assets.xml @@ -8,11 +8,9 @@ <link href="/lefilament_tdb/static/src/css/lefilament_tdb.css" rel="stylesheet" /> <script type="text/javascript" src="/lefilament_tdb/static/src/lib/highcharts.js"></script> - <script type="text/javascript" src="/lefilament_tdb/static/src/lib/chart.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/lib/xlsx.core.min.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/lib/FileSaver.min.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/lib/tableexport.js"></script> - <script type="text/javascript" src="/lefilament_tdb/static/src/lib/progressBar.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/js/lefilament_tdb.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/js/dashboard_year.js"></script>