mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 01:32:20 +00:00
ch2.7 Real life update
This commit is contained in:
parent
f89514d21f
commit
a9713b4667
|
@ -1,6 +1,6 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { Component, onWillStart } from "@odoo/owl";
|
||||
import { Component, onWillStart, useState } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { Layout } from "@web/search/layout";
|
||||
import { useService } from "@web/core/utils/hooks"
|
||||
|
@ -18,10 +18,7 @@ class AwesomeDashboard extends Component {
|
|||
|
||||
this.action = useService("action");
|
||||
|
||||
this.stats = useService('awesome_dashboard.statistics');
|
||||
onWillStart(async () => {
|
||||
this.stats = await this.stats.loadStatistics();
|
||||
});
|
||||
this.stats = useState(useService('awesome_dashboard.statistics'));
|
||||
}
|
||||
|
||||
openCustomers() {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
|
||||
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
|
||||
</t>
|
||||
<div class="d-flex flex-wrap">
|
||||
<div class="d-flex flex-wrap" t-if="stats.isReady">
|
||||
<DashboardItem>
|
||||
Number of new orders this month
|
||||
<div class="fs-1 fw-bold text-success text-center">
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { memoize } from "@web/core/utils/functions"
|
||||
import { reactive } from "@odoo/owl";
|
||||
|
||||
const statisticsService = {
|
||||
dependencies: ["rpc"],
|
||||
async: ["loadStatistics"],
|
||||
start(env, { rpc }) {
|
||||
return {
|
||||
loadStatistics: memoize(() => rpc("/awesome_dashboard/statistics")),
|
||||
};
|
||||
const statistics = reactive({ isReady: false });
|
||||
async function loadData() {
|
||||
const updates = await rpc("/awesome_dashboard/statistics");
|
||||
Object.assign(statistics, updates, { isReady: true });
|
||||
}
|
||||
setInterval(loadData, 10*60*1000);
|
||||
loadData();
|
||||
return statistics;
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue