odoo-tutorials/awesome_dashboard/static/src/dashboard/statistics_service.js
2024-09-20 15:55:56 -10:00

21 lines
618 B
JavaScript

/** @odoo-module **/
import { registry } from "@web/core/registry";
import { reactive } from "@odoo/owl";
const statisticsService = {
dependencies: ["rpc"],
start(env, { rpc }) {
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;
},
};
registry.category("services").add("awesome_dashboard.statistics", statisticsService);