콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2342 화면

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.

아바타
취소
관련 게시물 답글 화면 활동
0
7월 24
1172
0
8월 21
9222
1
6월 23
4520
1
3월 23
2660
2
12월 22
24228