Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2233 มุมมอง

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;});

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ค. 24
1164
0
ส.ค. 21
9191
1
มิ.ย. 23
4489
Odoo 14 - Send Email Contact Form URL แก้ไขแล้ว
1
มี.ค. 23
2622
2
ธ.ค. 22
24174