ch2.4 Call the server, add some statistics

This commit is contained in:
Matt Marcha 2024-09-20 14:01:41 -10:00
parent c0f193b52c
commit 7d74834fb7
2 changed files with 49 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/** @odoo-module **/ /** @odoo-module **/
import { Component } from "@odoo/owl"; import { Component, onWillStart } from "@odoo/owl";
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout"; import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks" import { useService } from "@web/core/utils/hooks"
@ -16,6 +16,11 @@ class AwesomeDashboard extends Component {
}; };
this.action = useService("action"); this.action = useService("action");
this.rpc = useService('rpc');
onWillStart(async () => {
this.stats = await this.rpc("/awesome_dashboard/statistics");
});
} }
openCustomers() { openCustomers() {

View file

@ -2,15 +2,55 @@
<templates xml:space="preserve"> <templates xml:space="preserve">
<t t-name="awesome_dashboard.AwesomeDashboard"> <t t-name="awesome_dashboard.AwesomeDashboard">
Total amount of new orders this month
<Layout display="display" className="'o_dashboard h-100'"> <Layout display="display" className="'o_dashboard h-100'">
<t t-set-slot="layout-buttons"> <t t-set-slot="layout-buttons">
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button> <button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
<button class="btn btn-primary" t-on-click="openLeads">Leads</button> <button class="btn btn-primary" t-on-click="openLeads">Leads</button>
</t> </t>
<div class="d-flex flex-wrap"> <div class="d-flex flex-wrap">
<DashboardItem /> <DashboardItem>
<DashboardItem size="2">That's a bigger one</DashboardItem> Number of new orders this month
<DashboardItem/> <div class="fs-1 fw-bold text-success text-center">
<t t-out="stats.nb_new_orders"/>
</div>
</DashboardItem>
<DashboardItem>
Total amount of new orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-out="stats.total_amount"/>
</div>
</DashboardItem>
<DashboardItem>
Average amount of t-shirt by order this month
<div class="fs-1 fw-bold text-success text-center">
<t t-out="stats.average_quantity"/>
</div>
</DashboardItem>
<DashboardItem>
Number of cancelled orders this month
<div class="fs-1 fw-bold text-success text-center">
<t t-out="stats.nb_cancelled_orders"/>
</div>
</DashboardItem>
<DashboardItem>
Average time for an order to go from new to sent or cancelled
<div class="fs-1 fw-bold text-success text-center">
<t t-out="stats.average_time"/>
</div>
</DashboardItem>
</div> </div>
</Layout> </Layout>
</t> </t>