Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
4458 Lượt xem

Good day all, im new to javascript and ive been looking into the source code for clues since the beginning and upgrading to odoo17. i noticed all the web.core and qweb.core declaration is gone. im still using odoo.define to declare my javascript. can anyone help me?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

you need to use 

/** @odoo-module */ 

as first line in the file and need to use class based components.

Ảnh đại diện
Huỷ bỏ
Tác giả

thank you for your reply. Now my confusion is how do you find the web.core component in the OWL way?

var core = require('web.core'); > import { core } from "@web/core"; ?

Câu trả lời hay nhất

hello i have the same probleme do you find a solutions ?

Ảnh đại diện
Huỷ bỏ
Tác giả

I have not found any specific solution for this. so what i did was just copy paste things till it worked. for example in my use case im trying to use the javascript for portal webform. i declared it like this.

/** @odoo-module */
import { markup } from "@odoo/owl";
import dom from "@web/legacy/js/core/dom";
import { cookie } from "@web/core/browser/cookie";;
import { loadWysiwygFromTextarea } from "@web_editor/js/frontend/loadWysiwygFromTextarea";
import publicWidget from "@web/legacy/js/public/public_widget";
import { session } from "@web/session";
import { escape } from "@web/core/utils/strings";
import { _t } from "@web/core/l10n/translation";
import { renderToElement } from "@web/core/utils/render";
import { browser } from "@web/core/browser/browser";
import { useService } from "@web/core/utils/hooks";

console.log('Javascript File loaded successfully :D');
publicWidget.registry.generic_form_data = publicWidget.Widget.extend({
//javascript codes here
});

thank you mohamad but the problem that i'm using qweb.render to render the template data and that's work in odoo V16 but in odoo17 i don't find the qweb.render it doesn't work , do you have an idea for that ? and thank you for your time :
this.$('.o_content').empty().append(QWeb.render("manage_timesheet_screen.employee", {
employee_ids: this.employee_ids,
employee: this.employee,
employees_list: this.employees_list,
employees_valid: this.employees_valid,
employees_count: this.employees_count,

period_ids: this.period_ids,
period_id: this.period_id,
}));

var html_employees_list = QWeb.render('manage_timesheet_screen.employees_list', {
employees_list: this.employee_ids,
employees_valid: this.employees_valid,
employees_count: this.employees_count,
employee_id: this.default_employee,
period_id: this.default_period_id,
});

Câu trả lời hay nhất

Hello, have you found any solution ?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 25
6971
2
thg 12 24
4831
1
thg 1 24
2808
0
thg 4 25
127
0
thg 12 24
622