Commit bf7d2873 authored by Juliana - Le Filament's avatar Juliana - Le Filament
Browse files

[MIG] Migration -> 13.0

parent 08e281c7
# 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': [
......
......@@ -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);
"""
)
......
......@@ -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')
......
......@@ -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',
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment