File tree Expand file tree Collapse file tree 5 files changed +53
-7
lines changed
awesome_dashboard/static/src Expand file tree Collapse file tree 5 files changed +53
-7
lines changed Original file line number Diff line number Diff line change 11/** @odoo -module **/
22
3- import { Component } from "@odoo/owl" ;
3+ import { Component , onWillStart } from "@odoo/owl" ;
44import { registry } from "@web/core/registry" ;
55import { Layout } from "@web/search/layout" ;
66import { useService } from "@web/core/utils/hooks" ;
@@ -20,7 +20,12 @@ class AwesomeDashboard extends Component {
2020 }
2121
2222 setup ( ) {
23- this . action = useService ( "action" ) ;
23+ this . action = useService ( "action" ) ;
24+ const statsService = useService ( "awesome_dashboard.getStats" ) ;
25+
26+ onWillStart ( async ( ) => {
27+ this . result = await statsService . loadStatistics ( ) ;
28+ } ) ;
2429 }
2530
2631 openCustomerKanban ( ) {
Original file line number Diff line number Diff line change 66 <Layout className =" 'o_dashboard h-100'" display =" props.display" >
77 <button class =" btn btn-primary myBtnChange" t-on-click =" openCustomerKanban" > Open customer kanban </button >
88 <button class =" btn btn-primary myBtnChange" t-on-click =" openActivity" > Leads </button >
9- <DashboardItem > long content </DashboardItem >
10- <DashboardItem size =" 2" > very very very very long content </DashboardItem >
9+ <div style =" margin-left: 1rem;" >
10+ <DashboardItem size =" 2" > Average quantity sold is :
11+ <span style =" color: green; font-weight: bolder; font-size: 27px;" >
12+ <t t-esc =" result.average_quantity" />
13+ </span >
14+ </DashboardItem >
15+ <DashboardItem size =" 2" > Number of new orders this month :
16+ <span style =" color: green; font-weight: bolder; font-size: 27px;" >
17+ <t t-esc =" result.nb_new_orders" />
18+ </span >
19+ </DashboardItem >
20+ <DashboardItem size =" 2" > Total amount of new orders this month :
21+ <span style =" color: green; font-weight: bolder; font-size: 27px;" >
22+ <t t-esc =" result.total_amount" />
23+ </span >
24+ </DashboardItem >
25+ <DashboardItem size =" 2" > Number of cancelled orders this month :
26+ <span style =" color: green; font-weight: bolder; font-size: 27px;" >
27+ <t t-esc =" result.nb_cancelled_orders" />
28+ </span >
29+ </DashboardItem >
30+ <DashboardItem size =" 2" > Average time for an order :
31+ <span style =" color: green; font-weight: bolder; font-size: 27px;" >
32+ <t t-esc =" result.average_time" />
33+ </span >
34+ </DashboardItem >
35+ </div >
1136 </Layout >
1237
1338 </div >
Original file line number Diff line number Diff line change 11.box {
2- border : 3px ;
2+ border : 30px black ;
3+ // border-color: black;
4+ border-radius : 10px ;
35 background-color : white ;
6+ margin : 1rem ;
47}
Original file line number Diff line number Diff line change 22<templates xml : space =" preserve" >
33
44 <t t-name =" awesome_dashboard.DashboardItem" >
5- <div class =" p-3 box" t-att-style =" 'width: ' + 18 * props.size + 'rem;'" >
5+ <span class =" p-3 box" t-att-style =" 'width: ' + 18 * props.size + 'rem;'" >
66 <t t-slot =" default" />
7- </div >
7+ </span >
88 </t >
99
1010</templates >
Original file line number Diff line number Diff line change 1+ import { registry } from "@web/core/registry" ;
2+ import { rpc } from "@web/core/network/rpc" ;
3+ import { memoize } from "@web/core/utils/functions" ;
4+
5+ export const getStatistics = {
6+ async start ( ) {
7+ return {
8+ loadStatistics : memoize ( ( ) => rpc ( "/awesome_dashboard/statistics" ) ) ,
9+ } ;
10+ } ,
11+ } ;
12+
13+ registry . category ( "services" ) . add ( "awesome_dashboard.getStats" , getStatistics ) ;
You can’t perform that action at this time.
0 commit comments