This repository has been archived on 2026-05-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
odoo-addons/addons/havari_license_client/static/src/js/license_bus.js

46 lines
1.6 KiB
JavaScript

/** @odoo-module **/
import { browser } from "@web/core/browser/browser";
import { registry } from "@web/core/registry";
/**
* License Bus Service
* Listens for license status updates from the server and reloads the page when needed.
*/
export const licenseBusService = {
dependencies: ["bus_service", "notification"],
start(env, { bus_service, notification }) {
// Subscribe to license status updates
bus_service.subscribe("license/status_update", (payload) => {
console.log("License status update received:", payload);
const { module_name, action, state, message, requires_reload } = payload;
// Show notification to user
if (action === "suspend" || action === "revoke") {
notification.add(message || `License for ${module_name} has been ${state}`, {
title: "License Status Changed",
type: "danger",
sticky: true,
});
// Reload page after 3 seconds to apply changes
if (requires_reload) {
setTimeout(() => {
browser.location.reload();
}, 3000);
}
} else if (action === "activate") {
notification.add(message || `License for ${module_name} has been activated`, {
title: "License Activated",
type: "success",
sticky: false,
});
}
});
},
};
registry.category("services").add("license_bus", licenseBusService);