Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Le Filament
lefilament_tdb
Commits
04b5bd01
Commit
04b5bd01
authored
Sep 22, 2017
by
Benjamin
Browse files
add cca
parent
95fa9916
Changes
2
Hide whitespace changes
Inline
Side-by-side
models/lefilament_tdb.py
View file @
04b5bd01
...
...
@@ -190,5 +190,13 @@ class LeFilamentTdb(models.Model):
order by date_trunc('month', date);"""
)
tresorerie
=
self
.
_cr
.
dictfetchall
()
return
tresorerie
self
.
_cr
.
execute
(
"""SELECT to_char(date_trunc('month', e.date),'YYYY-MM') as mois,
sum(es.total_amount) as cca
from hr_expense_sheet es, hr_expense e
where es.id = e.sheet_id and e.payment_mode='own_account' and es.state!='done'
group by date_trunc('month', e.date)
order by date_trunc('month', e.date);"""
)
cca
=
self
.
_cr
.
dictfetchall
()
return
{
'tresorerie'
:
tresorerie
,
'cca'
:
cca
}
static/src/js/tresorerie.js
View file @
04b5bd01
...
...
@@ -50,11 +50,12 @@ odoo.define('lefilament_tdb.tresorerie', function (require) {
var
sortie
=
[];
var
variation
=
[];
var
treso
=
[];
var
cca
=
[];
var
labels
=
[];
var
tabLength
=
this
.
values
.
length
-
1
;
var
tabLength
=
this
.
values
.
tresorerie
.
length
-
1
;
_
.
each
(
this
.
values
,
function
(
value
,
key
)
{
_
.
each
(
this
.
values
.
tresorerie
,
function
(
value
,
key
)
{
if
(
key
==
0
)
{
treso
.
push
(
value
.
variation
);
}
else
{
...
...
@@ -65,16 +66,17 @@ odoo.define('lefilament_tdb.tresorerie', function (require) {
});
for
(
var
i
=
(
tabLength
-
11
);
i
<
tabLength
+
1
;
i
++
)
{
entree
.
push
(
this
.
values
[
i
].
entree
);
sortie
.
push
(
this
.
values
[
i
].
sortie
*
(
-
1
)
);
variation
.
push
(
this
.
values
[
i
].
variation
);
labels
.
push
(
moment
(
this
.
values
[
i
].
mois
).
format
(
'
MMM YYYY
'
));
entree
.
push
(
this
.
values
.
tresorerie
[
i
].
entree
);
sortie
.
push
(
this
.
values
.
tresorerie
[
i
].
sortie
*
(
-
1
)
);
variation
.
push
(
this
.
values
.
tresorerie
[
i
].
variation
);
cca
.
push
(
this
.
values
.
cca
[
i
].
cca
);
labels
.
push
(
moment
(
this
.
values
.
tresorerie
[
i
].
mois
).
format
(
'
MMM YYYY
'
));
}
console
.
log
(
treso
.
slice
(
tabLength
-
11
,
tabLength
+
1
));
var
datasets
=
[
{
label
:
'
Trésorerie
'
,
data
:
treso
.
slice
(
tabLength
-
11
,
tabLength
+
1
),
backgroundColor
:
'
transparent
'
,
borderColor
:
'
#5E8ED5
'
},
{
label
:
'
CCA
'
,
data
:
cca
,
backgroundColor
:
'
transparent
'
,
borderColor
:
'
#FFA063
'
},
{
label
:
'
Variation
'
,
data
:
variation
,
backgroundColor
:
'
rgba(255, 197, 98, 0.3)
'
,
borderColor
:
'
#FFC562
'
},
{
label
:
'
Entrées
'
,
data
:
entree
,
backgroundColor
:
'
rgba(81, 210, 183, 0.3)
'
,
borderColor
:
'
#51d2b7
'
},
{
label
:
'
Sorties
'
,
data
:
sortie
,
backgroundColor
:
'
rgba(249, 96, 117, 0.3)
'
,
borderColor
:
'
#F96075
'
},
...
...
@@ -87,106 +89,10 @@ odoo.define('lefilament_tdb.tresorerie', function (require) {
datasets
:
datasets
};
// var options = {
// legend: {
// display: false,
// },
// layout: {
// padding: { left:0, right: 0, bottom: 20, top: 20, },
// },
// scales: {
// xAxes: [{
// stacked: true,
// scaleShowLabels: false,
// display : false ,
// }],
// yAxes: [{
// stacked: true,
// scaleShowLabels: false,
// display : false ,
// }]
// },
// tooltips: {
// backgroundColor: 'rgba(255,255,255,0.8)',
// titleFontStyle: 'normal',
// titleFontColor: '#999',
// bodyFontColor: '#777',
// callbacks: {
// label: function(tooltipItems, data) {
// return (tooltipItems.xLabel * self.target / 100000).toLocaleString('fr', { maximumFractionDigits: 2 }) + ' K€';
// }
// }
// },
// responsive: true,
// }
var
myLineChart
=
new
Chart
(
this
.
ctx
,
{
type
:
'
line
'
,
data
:
this
.
targetData
,
}
);
},
render_monetary
:
function
(
value
)
{
value
=
value
.
toLocaleString
(
'
fr
'
,
{
maximumFractionDigits
:
0
})
+
'
€
'
;
return
value
;
},
render_keur
:
function
(
value
)
{
value
=
(
value
/
1000
).
toLocaleString
(
'
fr
'
,
{
maximumFractionDigits
:
0
})
+
'
K€
'
;
return
value
;
},
render_percent
:
function
(
value
)
{
value
=
value
.
toLocaleString
(
'
fr
'
,
{
maximumFractionDigits
:
1
})
+
'
%
'
;
return
value
;
},
render_date
:
function
(
value
)
{
var
dateFormat
=
new
Date
(
value
);
var
new_value
=
moment
(
dateFormat
).
format
(
'
Do MMM YYYY
'
);
return
new_value
;
},
render_monetary_color
:
function
(
value
)
{
if
(
value
>=
0
)
value
=
'
<span class="positive">
'
+
value
.
toLocaleString
(
'
fr
'
,
{
maximumFractionDigits
:
0
})
+
'
€</span>
'
;
else
value
=
'
<span class="negative">
'
+
value
.
toLocaleString
(
'
fr
'
,
{
maximumFractionDigits
:
0
})
+
'
€</span>
'
;
return
value
;
},
facture
:
function
()
{
var
self
=
this
;
var
context
=
{
'
user_id
'
:
this
.
session
.
uid
,
}
var
action
=
({
type
:
'
ir.actions.act_window
'
,
res_model
:
'
account.invoice
'
,
view_type
:
'
form
'
,
view_mode
:
'
tree,form
'
,
views
:
[[
false
,
'
list
'
],
[
false
,
'
form
'
]],
domain
:
[[
'
state
'
,
'
=
'
,
'
open
'
],[
'
type
'
,
'
=
'
,
'
out_invoice
'
]],
target
:
'
current
'
,
name
:
'
Factures en cours
'
,
context
:
context
})
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
})
this
.
do_action
(
action
);
},
});
core
.
action_registry
.
add
(
'
lefilament_tdb.tresorerie
'
,
TresorerieView
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment