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

odoo.define('module.name', function(require) {

'use strict';

var options = require('web_editor.snippets.options');

varajax = require('web.ajax');

var core = require('web.core');

var qweb = core.qweb;

var_t = core._t;

ajax.loadXML('/module/static/src/xml/cookie_bar.xml', qweb);

}

);

This is the piece of code where the error occurs.


Uncaught Promise > ajax.loadXML is not a function 

This is the error message.  Has loadXML changed into something else in odoo16? as im trying to upgrade it from odoo15  where this code worked perfectly but in 16 it does not

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

try this way:

odoo.define('module.name', function (require) {
'use strict';

var ajax = require('web.ajax');
var core = require('web.core');

var qweb = core.qweb;

// Load the XML templates
ajax.loadAsset('module.name', 'xml', '/module/static/src/xml/cookie_bar.xml', { }, qweb).then(function () {
// Templates loaded, you can now use them
var renderedTemplate = qweb.render('module.cookie_bar_template', { /* template variables */ });
// Use the rendered template as needed
});
});

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

This is exactly what i needed.Thanks

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 24
1646
2
thg 9 23
3858
0
thg 7 25
313
1
thg 7 25
5107
0
thg 7 25
668