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

Hi good day everyone, 

I just want to ask how can I load the Js in odoo17 I work with odoo14 when I try to upgrade to odoo17 I have Iusse in Js load 

Thank you very much again in advance.

Sincerely yours,

Alrabie

{

    "name": "Dashboard Core",

    "version": "17.0.1.0.0",


    "qweb": ["static/src/xml/dashboard.xml"],

   

    "assets": {

        'web.assets_backend': [

            'dashboard_base/static/src/js/dashboard.js',

        ],


},

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

var core = require("web.core"); var Dashboard = require("dashboard_base.Dashboard");

var DashboardHr = Dashboard.extend({ init: function (parent, context) { this._super(parent, context); this.dashboards_templates = ["hr_dashboard.graphs"]; },

fetch_data: function () { var self = this; return self._fetch_data("/hr_dashboard/fetch_dashboard_data"); }, render_graphs: function () { var self = this;

// Graph : Employees by department var datasets = [ { backgroundColor: window.randomBackgroundColors, borderWidth: 1, data: self.data.employees_by_department, }, ]; var option = { responsive: true, legend: { display: true, position: "top", }, }; self.render_graph("#pieChartEmployeesByDepartment", "pie", self.data.departments, datasets, option); // Graph : Contracts By States datasets = [ { backgroundColor: window.randomBackgroundColors, borderWidth: 1, data: self.data.contracts_by_states, }, ]; option = { responsive: true, legend: { display: true, position: "top", }, }; self.render_graph("#pieChartContractsByStates", "pie", self.data.all_states, datasets, option); }, });

core.action_registry.add("hr_dashboard", DashboardHr); return DashboardHr;});

Avatar
Verwerfen
Beste Antwort

Hi,

You're trying to upgrade your Odoo 14 module to work with Odoo 17. But in Odoo 17, the way assets are defined has changed. Update your __manifest__.py file like this:

{

    "name": "Dashboard Core",

    "version": "17.0.1.0.0",

    "assets": {

        'web.assets_backend': [

            'dashboard_base/static/src/js/dashboard.js',

            'dashboard_base/static/src/xml/dashboard.xml',

        ],

    },

}

And also js is completely changed to owl in odoo 17. So you need to update your JavaScript file like the following code:

/** @odoo-module **/


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

import { BaseDashboard } from "@dashboard_base/js/base_dashboard";


class HrDashboard extends BaseDashboard {

    setup() {

        super.setup();

        this.dashboards_templates = ["hr_dashboard.graphs"];

    }

    async fetchData() {

        return this.rpc("/hr_dashboard/fetch_dashboard_data");

    }

    renderGraphs() {

        // Your graph rendering logic here

        // You'll need to update this to use a charting library compatible with Odoo 17

    }

}

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

export default HrDashboard;


Hope it helps.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Juli 24
1164
0
Aug. 21
9191
1
Juni 23
4489
1
März 23
2622
2
Dez. 22
24174