Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
486 Vistas



I need to auto refresh this kanban board , if new tickets are created by other users and assigned to me. It should auto reflect in my kanban board , without manual refresh the board to show new tickets or any updates on ticket.

Avatar
Descartar
Mejor respuesta

Hi,

you can use the JS code below and include it in your custom module. Once installed, it will automatically refresh the Kanban view whenever new tickets are created.


JS CODE:


/** @odoo-module **/


import { KanbanController } from "@web/views/kanban/kanban_controller";

import { patch } from "@web/core/utils/patch";

import { useService } from "@web/core/utils/hooks";

import { onMounted, onWillUnmount } from "@odoo/owl";


patch(KanbanController.prototype, {

    name: "help_desk_increment_refresh",


    setup() {

        super.setup?.(...arguments);

        if (this.props.resModel !== "helpdesk.ticket") return;


        const orm = useService("orm");

        const action = useService("action");

        let previousCount = null;

        let interval = null;


        onMounted(() => {

            interval = setInterval(async () => {

                const count = await orm.searchCount("helpdesk.ticket", []);

                // Only refresh if previousCount is set and count increased

                if (previousCount !== null && count > previousCount) {

                    await action.doAction({ type: "ir.actions.client", tag: "reload" }, { replaceLastAction: true });

                }

                previousCount = count;

            }, 5000); // check every 5 seconds

        });


        onWillUnmount(() => clearInterval(interval));

    },

});


for more details you can refer this blog: https://www.cybrosys.com/blog/overview-of-real-time-kanban-boards-in-odoo-18-with-auto-updates


Hope it helps.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 25
586
0
mar 25
1948
0
oct 24
1927
1
sept 24
2005
1
ago 24
2055