mirror of
https://github.com/SARL-PACIFIC-ERP/odoo-sh-test.git
synced 2025-06-25 09:32:22 +00:00
ch2.7 Real life update
This commit is contained in:
parent
f89514d21f
commit
a9713b4667
|
@ -1,6 +1,6 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import { Component, onWillStart } from "@odoo/owl";
|
import { Component, onWillStart, useState } 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"
|
||||||
|
@ -18,10 +18,7 @@ class AwesomeDashboard extends Component {
|
||||||
|
|
||||||
this.action = useService("action");
|
this.action = useService("action");
|
||||||
|
|
||||||
this.stats = useService('awesome_dashboard.statistics');
|
this.stats = useState(useService('awesome_dashboard.statistics'));
|
||||||
onWillStart(async () => {
|
|
||||||
this.stats = await this.stats.loadStatistics();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openCustomers() {
|
openCustomers() {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<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" t-if="stats.isReady">
|
||||||
<DashboardItem>
|
<DashboardItem>
|
||||||
Number of new orders this month
|
Number of new orders this month
|
||||||
<div class="fs-1 fw-bold text-success text-center">
|
<div class="fs-1 fw-bold text-success text-center">
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import { registry } from "@web/core/registry";
|
import { registry } from "@web/core/registry";
|
||||||
import { memoize } from "@web/core/utils/functions"
|
import { reactive } from "@odoo/owl";
|
||||||
|
|
||||||
const statisticsService = {
|
const statisticsService = {
|
||||||
dependencies: ["rpc"],
|
dependencies: ["rpc"],
|
||||||
async: ["loadStatistics"],
|
|
||||||
start(env, { rpc }) {
|
start(env, { rpc }) {
|
||||||
return {
|
const statistics = reactive({ isReady: false });
|
||||||
loadStatistics: memoize(() => rpc("/awesome_dashboard/statistics")),
|
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