diff --git a/__manifest__.py b/__manifest__.py index 119b63f0fd47252830e8063dbcd001248559520f..5578dc0429417fb8c9965ccce71d7a47ce16f5e8 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,4 +1,6 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# © 2021 Le Filament (<https://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + { 'name': "Le Filament - Tableau de Bord", @@ -18,7 +20,7 @@ 'author': "LE FILAMENT", 'category': 'dashboard', 'website': "https://le-filament.com", - 'version': '12.0.1.0.0', + 'version': '13.0.1.0.0', 'license': 'AGPL-3', 'depends': ['account', 'crm', 'hr_expense', 'sale'], 'data': [ diff --git a/models/lefilament_tdb.py b/models/lefilament_tdb.py index 843d7bdd7b37281bb5458dbba56a92788e533c1e..42ba8170d794f15f0b469a5c882954a6ca48159d 100644 --- a/models/lefilament_tdb.py +++ b/models/lefilament_tdb.py @@ -33,7 +33,6 @@ class LeFilamentTdb(models.Model): charges_fixes = fields.Float('Charges Fixes', default=10000) runway = fields.Float('Runway', compute="runway_value") - @api.multi @api.depends('date_tdb') def dashboard_values(self): for record in self: @@ -43,7 +42,7 @@ class LeFilamentTdb(models.Model): # FACTURÉ self.env.cr.execute( "SELECT SUM(amount_untaxed_signed) \ - FROM account_invoice \ + FROM account_move \ WHERE state != 'draft' \ AND (type = 'out_invoice' OR type = 'out_refund') \ AND date >= date_trunc('month', %s) \ @@ -123,14 +122,12 @@ class LeFilamentTdb(models.Model): record.charges_fixes = charges_fixes record.pipe_mois = pipe - @api.multi @api.depends('charges_fixes', 'treso') def runway_value(self): for record in self: if record.charges_fixes: record.runway = record.treso / record.charges_fixes - @api.multi @api.depends('date_tdb') def get_month(self): for record in self: @@ -158,8 +155,8 @@ class LeFilamentTdb(models.Model): # Get fiscal years fiscal_date = datetime( datetime.now().year, - self.env.user.company_id.fiscalyear_last_month, - self.env.user.company_id.fiscalyear_last_day + int(self.env.company.fiscalyear_last_month), + int(self.env.company.fiscalyear_last_day) ) if datetime.now() > fiscal_date: fiscal_year = "'" + Date.to_string(fiscal_date) + "'" @@ -196,20 +193,20 @@ class LeFilamentTdb(models.Model): """ SELECT (SELECT COUNT(*) - FROM account_invoice + FROM account_move ) AS id, (SELECT SUM(amount_untaxed_signed) - FROM account_invoice + FROM account_move WHERE state!='draft' AND (type='out_invoice' OR type='out_refund') AND date > %s AND date <= %s ) AS facture, - (SELECT SUM(residual_company_signed) - FROM account_invoice + (SELECT SUM(amount_residual_signed) + FROM account_move WHERE state!='draft' AND type='out_invoice' ) AS a_encaisser, - (SELECT SUM(residual_company_signed) - FROM account_invoice + (SELECT SUM(amount_residual_signed) + FROM account_move WHERE state!='draft' AND type='in_invoice' ) AS a_payer, (SELECT SUM(planned_revenue * probability / 100) @@ -380,19 +377,19 @@ class LeFilamentTdb(models.Model): self._cr.execute( """ - SELECT to_char(date_trunc('month', date_due),'YYYY-MM') AS mois, + SELECT to_char(date_trunc('month', invoice_date_due),'YYYY-MM') AS mois, SUM(CASE WHEN type = 'in_invoice' - THEN residual_company_signed + THEN amount_residual_signed ELSE 0 END ) AS f_fournisseur, SUM(CASE WHEN type = 'out_invoice' - THEN residual_company_signed + THEN amount_residual_signed ELSE 0 END ) AS f_client - FROM account_invoice + FROM account_move WHERE state != 'draft' AND state != 'paid' - GROUP BY date_trunc('month', date_due) - ORDER BY date_trunc('month', date_due); + GROUP BY date_trunc('month', invoice_date_due) + ORDER BY date_trunc('month', invoice_date_due); """ ) factures = self._cr.dictfetchall() @@ -402,7 +399,7 @@ class LeFilamentTdb(models.Model): SELECT periode, SUM(montant) FROM previ_treso - WHERE periode != 1 + WHERE periode != '1' GROUP BY periode ORDER BY periode; """ @@ -414,7 +411,7 @@ class LeFilamentTdb(models.Model): SELECT to_char(date_trunc('month', date), 'YYYY-MM') as mois, SUM(montant) FROM previ_treso - WHERE periode = 1 + WHERE periode = '1' GROUP BY date_trunc('month', date); """ ) diff --git a/models/res_company.py b/models/res_company.py index 6dbc4e060e01a50aa53948e7af7e64d976689a87..e100ca75eb9cae0a8a59655779c6193c48140947 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -22,10 +22,10 @@ class previ_treso(models.Model): company_id = fields.Many2one( 'res.company', 'Company', - default=lambda self: self.env.user.company_id.id) + default=lambda self: self.env.user.company.id) name = fields.Char('Nom') periode = fields.Selection( - [(12, 'Mensuel'), (3, 'Trimestriel'), (1, 'Annuel')], + [('12', 'Mensuel'), ('3', 'Trimestriel'), ('1', 'Annuel')], srting='Période' ) date = fields.Date('Date') diff --git a/static/src/js/dashboard_year.js b/static/src/js/dashboard_year.js index 8b53beddd04ac8346dccd31f6690e8ac33d55932..a7aa59c86da2164af2f100f003ce1d0fb3220c52 100644 --- a/static/src/js/dashboard_year.js +++ b/static/src/js/dashboard_year.js @@ -53,7 +53,7 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var invoice_view_id = this._rpc({ model: 'ir.model.data', method: 'xmlid_to_res_id', - args: ['account.invoice_form'], + args: ['account.view_move_form'], }).then(function(results) { self.invoice_view_id = results; }); @@ -227,8 +227,7 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', - res_model: 'account.invoice', - view_type: 'form', + res_model: 'account.move', view_mode: 'tree,form', views: [[false, 'list'], [false, 'pivot'], [false, 'graph'], [self.invoice_view_id, 'form']], domain: [['state','in',['open','paid']],['type','in',['out_invoice', 'out_refund']],['date_invoice','>=',fiscalyear]], @@ -246,7 +245,6 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { 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']], @@ -264,7 +262,6 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', res_model: 'crm.lead', - view_type: 'form', view_mode: 'tree,form', views: [[false, 'kanban'], [false, 'list'], [this.pipe_view_id, 'form']], domain: ['|',['date_deadline','<=', fiscalyearnext],['date_deadline','=', null], ['type','=','opportunity'] ], @@ -282,7 +279,6 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', res_model: 'crm.lead', - view_type: 'form', view_mode: 'kanban,tree,form', views: [[false, 'kanban'], [false, 'list'], [this.pipe_view_id, 'form']], domain: [['type','=','opportunity'],['date_deadline','>', fiscalyearnext]], @@ -299,8 +295,7 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', - res_model: 'account.invoice', - view_type: 'form', + res_model: 'account.move', view_mode: 'tree,form', views: [[false, 'list'], [false, 'pivot'], [false, 'graph'], [self.invoice_view_id, 'form']], domain: [['state','=','open'],['type','=','out_invoice']], @@ -317,8 +312,7 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', - res_model: 'account.invoice', - view_type: 'form', + res_model: 'account.move', view_mode: 'tree,form', views: [[false, 'list'], [false, 'form']], domain: [['state','=','open'],['type','=','in_invoice']], @@ -336,7 +330,6 @@ odoo.define('lefilament_tdb.dashboard_year', function (require) { var action = ({ type: 'ir.actions.act_window', res_model: 'account.bank.statement', - view_type: 'form', view_mode: 'tree,form', views: [[false, 'list'], [false, 'form']], target:'current', diff --git a/views/schedule.xml b/views/schedule.xml index e6d210deb31eac6e465136f73ca13d8118596bbc..b62f4b1dabec89b45a3128cb1e7b40e2bff9f293 100644 --- a/views/schedule.xml +++ b/views/schedule.xml @@ -10,7 +10,7 @@ <field name="interval_number">1</field> <field name="interval_type">months</field> <field name="numbercall">-1</field> - <field name="doal">1</field> + <field name="doall" eval="True"/> <field name="nextcall" >2017-01-31 23:10:00</field> <field name="model_id" ref="model_lefilament_dashboard" /> <field name="code">model._new_data()</field>