Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
2585 Ansichten

hi,

I working on the dashboard using JS template, the XML template is not loading I get a screen with three block. 

here's the javascript code :


odoo.define('hr_dashboard.Dashboard', function (require) {
"use strict";

var AbstractAction = require('web.AbstractAction');
var core = require('web.core');
var Dashboard = AbstractAction.extend({
template: 'DashboardMain',
});

core.action_registry.add('custom_hr_dashboard', Dashboard);

return Dashboard;
});

here's the xml:






Hello odoo


this my first dashboard






here's xml view files which load the JS template:



HR Dashboard
custom_hr_dashboard


name=" Hr Dashboard"
action="hr_dashboard_action"
sequence="-200"/>





























Avatar
Verwerfen
Beste Antwort

Hi,


If you want to build a custom dashboard properly in Odoo (using JS + XML), here’s the correct structure you should follow:


JavaScript Code

import { AbstractAction } from "@web/webclient/actions/abstract_action";

import { registry } from "@web/core/registry";


export class HrDashboard extends AbstractAction {

    setup() {

        super.setup(...arguments);

    }

}


HrDashboard.template = "hr_dashboard.DashboardMain";


registry.category("actions").add("custom_hr_dashboard", HrDashboard);



XML Template (QWeb)


<?xml version="1.0" encoding="UTF-8"?>

<odoo>

    <template id="DashboardMain" name="Dashboard Main">

        <div class="oe_structure">

            <h1>Hello Odoo</h1>

            <p>This is my first dashboard.</p>

        </div>

    </template>

</odoo>


Action or menu view.


<odoo>

    <record id="hr_dashboard_action" model="ir.actions.client">

        <field name="name">HR Dashboard</field>

        <field name="tag">custom_hr_dashboard</field> <!-- Same as JS action_registry key -->

    </record>


    <menuitem id="menu_hr_dashboard"

              name="Dashboard"

              action="hr_dashboard_action"

              sequence="10"

              parent="hr.menu_hr_root"

              groups="base.group_user"/>

</odoo>


The tag in ir.actions.client must match the one you used in registry.category("actions").add(...) (which is "custom_hr_dashboard").


Also Refer the blog:


https://www.cybrosys.com/blog/how-to-create-dashboard-in-odoo-18


Hope this helps

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 24
745
0
Okt. 22
1957
0
Sept. 22
1064
1
Juli 22
4703
0
Juni 22
836