Skip to content
Extraits de code Groupes Projets
Valider b216ec79 rédigé par Benjamin's avatar Benjamin
Parcourir les fichiers

add fichiers

parent be9022a0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class res_company(models.Model):
_name = "res.company"
_inherit = "res.company"
ca_target = fields.Integer( "Objectif Chiffre d'Affaire" )
charges_fixes = fields.Integer( "Charges Fixes" )
\ No newline at end of file
odoo.define('sapoval_tdb.dashboard_year', function (require) {
"use strict";
var core = require('web.core');
var formats = require('web.formats');
var Model = require('web.Model');
var session = require('web.session');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var _t = core._t;
var _lt = core._lt;
var YearDashboardView = Widget.extend({
template: 'YearDashboard',
events: {
// 'click .card': function() {
// this.mychart.reflow();
// },
'click #facture_non_encaisse': function() {
this.facture();
},
'click #commandes': function() {
this.commandes();
},
},
init: function() {
var result = this._super.apply(this, arguments);
return result;
},
willStart: function() {
var deferred = new jQuery.Deferred();
var self = this;
this.values = {};
this.progess = 0;
var dash_model = new Model('sapoval.dashboard');
dash_model.call('retrieve_datas_dashboard')
.then(function(results) {
self.values = results;
self.progress = results.facture / results.target;
self.pfact = (self.values.facture / self.values.target * 100).toFixed(0);
self.pcomm = (self.values.commandes / self.values.target * 100).toFixed(0);
self.ppipe_win = (self.values.pipe_win / self.values.target * 100).toFixed(0);
self.ppipe_to_win = (self.values.pipe_to_win / self.values.target * 100).toFixed(0);
self.ptarg = 100-self.pfact-self.pcomm-self.ppipe_win-self.ppipe_to_win;
self.ptarg_sans_pipe = 100-self.pfact-self.pcomm-self.ppipe_win;
self.pfact2 = (self.values.facture);
self.pcomm2 = (self.values.commandes);
self.ppipe2_win = (self.values.pipe_win);
self.ppipe2_to_win = (self.values.pipe_to_win);
self.ptarg2 = self.values.target -self.pfact2-self.pcomm2-self.ppipe2_to_win-self.ppipe2_win;
self.ptarg2_sans_pipe = self.values.target -self.pfact2-self.pcomm2-self.ppipe2_to_win;
deferred.resolve();
});
return jQuery.when(this._super.apply(this, arguments),deferred);
},
start: function() {
return this.render_chart();
},
render_chart: function(chart) {
self = this;
/////////////////////////////////////////
// Etat d'avancement -> Bar Chart //
/////////////////////////////////////////
this.ctx = this.$el.find('#target')[0].getContext('2d');
// var dataset_stacked = [
// { label: 'Facturé', data: [this.pfact], backgroundColor: '#8ED8A2', },
// { label: 'Commandes', data: [this.pcomm], backgroundColor: '#F6DCA2', },
// { label: 'Gagné', data: [this.ppipe_win], backgroundColor: '#F6CCA2', },
// { label: 'Pipe', data: [this.ppipe_to_win], backgroundColor: '#F6ACA2', },
// { label: 'To Do', data: [this.ptarg], backgroundColor: '#eee', }];
var dataset_stacked = [
{ label: 'Facturé', data: [this.pfact2], backgroundColor: '#8ED8A2', },
{ label: 'Commandes', data: [this.pcomm2], backgroundColor: '#F6DCA2', },
{ label: 'Gagné', data: [this.ppipe2_win], backgroundColor: '#F6CCA2', },
{ label: 'To Do', data: [this.ptarg2_sans_pipe], backgroundColor: '#eee', }];
var label = 'Année ' + moment(Date.now()).format('YYYY');
this.targetData = {
labels : [label],
datasets : dataset_stacked
};
var options = {
legend: {
display: false,
position: 'bottom',
fullWidth: 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 / 1000).toLocaleString('fr', { maximumFractionDigits: 2 }) + ' K€';
}
}
},
responsive: true,
}
var myLineChart = new Chart(this.ctx, { type: 'horizontalBar', data: this.targetData, options } );
},
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('sapoval_tdb.dashboard_year', YearDashboardView);
});
Ce diff est replié.
Ce diff est replié.
Ce diff est replié.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Company Form -->
<record id="view_form_sapoval_company_form_inherited" model="ir.ui.view">
<field name="name">res.company.form.tdb</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//page[1]" position="after">
<page name="tdb" string="Tableau de Bord">
<group>
<group srting="Données Annuelles">
<field name="ca_target" />
</group>
<group srting="Données Mensuelles">
<field name="charges_fixes" />
</group>
</group>
</page>
</xpath>
</field>
</record>
</data>
</odoo>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter