diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py index e966da9a8e4bf596aaca4d6a44f58634767b7d60..1c8e2792bcbeb8aa7ed7e72494e2e90cf57fafdd 100644 --- a/models/lefilament_tdb.py +++ b/models/lefilament_tdb.py @@ -98,8 +98,8 @@ class LeFilamentTdb(models.Model): def new_data(self): self.create({ 'date_tdb': str(datetime.now()) }) - - def retrieve_datas_dashboard(self, cr, uid, context=None): + @api.model + def retrieve_datas_dashboard(self): res = { 'facture': 0, 'commandes': 0, @@ -110,12 +110,14 @@ class LeFilamentTdb(models.Model): 'entree': 0, 'sortie': 0, 'variation': 0, - 'target': 100000, + 'target': 0, 'cca': 0, 'capital': 0, 'date_maj': 0, + 'a_encaisser': 0, } - cr.execute(""" + + self._cr.execute(""" SELECT (select count(*) from account_invoice) as id, (select sum(amount_untaxed) from account_invoice where state!='draft' and type='out_invoice' and date >= date_trunc('year', current_date) ) as facture, @@ -130,13 +132,13 @@ class LeFilamentTdb(models.Model): (select sum(amount) from account_bank_statement_line where date >= date_trunc('year', current_date) ) as variation, (select sum(total_amount) from hr_expense where payment_mode='own_account' and state!='done' ) as cca, (select sum(price_subtotal-qty_invoiced*price_unit) from sale_order_line where invoice_status='to invoice') as commandes; """) - datas = cr.dictfetchall() + datas = self._cr.dictfetchall() - cr.execute("select ca_target from res_company;") - ca_target = cr.dictfetchall() + self._cr.execute("select ca_target from res_company;") + ca_target = self._cr.dictfetchall() - cr.execute("select sum(capital) as capital from hr_employee;") - capital = cr.dictfetchall() + self._cr.execute("select sum(capital) as capital from hr_employee;") + capital = self._cr.dictfetchall() res['facture'] =+ datas[0]['facture'] res['a_encaisser'] =+ datas[0]['a_encaisser'] diff --git a/static/src/css/lefilament_tdb.css b/static/src/css/lefilament_tdb.css index cc0c993e7d49ef0fa331f02263c2fc2cf46b32ac..8f0135c392487d77f88ffef0e914fd72da3b9649 100644 --- a/static/src/css/lefilament_tdb.css +++ b/static/src/css/lefilament_tdb.css @@ -1,6 +1,6 @@ .tdb_form { margin: 20px 0; } -.content { width: calc(100% - 190px); padding: 10px 25px; } +.content { width: calc(100% - 190px); padding: 10px 25px; background-color: #fff; } .content h3 { font-size: 20px; margin: 20px 0; } .tableau { overflow: auto; margin-left: 150px; font-size: 11px; margin-top: 30px; } diff --git a/static/src/js/dashboard_year.js b/static/src/js/dashboard_year.js index 9bc5bff92f55663f0e11156606362d8610f3b21e..7d3d3a21ae53f08650ce77aaa7845406142580e6 100644 --- a/static/src/js/dashboard_year.js +++ b/static/src/js/dashboard_year.js @@ -1,4 +1,5 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { + "use strict"; var core = require('web.core'); var formats = require('web.formats'); @@ -35,9 +36,11 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var deferred = new jQuery.Deferred(); var self = this; this.values = {}; - this.progess = 0 - new Model('lefilament.dashboard') - .call('retrieve_datas_dashboard', []) + this.progess = 0; + + var dash_model = new Model('lefilament.dashboard'); + console.log(dash_model); + dash_model.call('retrieve_datas_dashboard') .then(function(results) { self.values = results; self.progress = results.facture / results.target; @@ -47,7 +50,6 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { }, start: function() { - // session.on("request", this, this.render_chart); return this.render_chart(); }, @@ -65,7 +67,7 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { 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]; + var hchart = this.$el.find('#hchart')[0]; Highcharts.setOptions({ colors: ['#8ED8A2', '#F6DCA2', '#F6CCA2', '#F6ACA2', '#eee'], });