跳至内容
菜单
此问题已终结
2 回复
2838 查看

odoo.define( 'vendor_portal_validation.vendor_portal' , function (require) {
'use strict' ;

var core = require( 'web.core' );
var ajax = require( 'web.ajax' );
var Dialog = require( ' web.Dialog' );
var qweb = core.qweb;
var rpc = require( "web.rpc" );
var _t = core._t;
var session = require( 'web.session' );
const {assets} = require ( '@web/core/assets' );

assets.loadXML('/vendor_portal_validation/static/src/xml/vendor_portal.xml' ).then( function () {



how to load xml  in odoo 16  js?



形象
丢弃
编写者 最佳答案

var   xml_id="/ vendor_portal_validation /static/src/xml/vendor_portal.xml"

    function parseXML(xml_id) {

         var xml = input.responseXML || input.responseText;

         var doc;

    try {

        var parser = new DOMParser();

        doc = parser.parseFromString(xml, "application/xml");

    } catch(err) {

        doc = new ActiveXObject("Microsoft.XMLDOM");

        doc.async = false;

        doc.loadXML(xml);

    }};

形象
丢弃
最佳答案

Hi,
You can try ajax.loadAsset method and pass the template inside it.
var core = require( 'web.core' );
var ajax = require( 'web.ajax' );
var Dialog = require( ' web.Dialog' );
var qweb = core.qweb;
var rpc = require( "web.rpc" );
var _t = core._t;
var session = require( 'web.session' );
const {assets} = require ( '@web/core/assets' );
// Load the XML templates
ajax.loadAsset('vendor_portal_validation', 'xml', '/vendor_portal_validation/static/src/xml/vendor_portal.xml', { }, qweb).then(function () {
// Templates loaded, you can now use them
var renderedTemplate = qweb.render('vendor_portal_validation.template_name', { /* template variables */ });
// Use the rendered template as needed
});
});


Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
2
2月 24
81
1
12月 23
1406
0
9月 23
2117
0
8月 23
1289
0
11月 24
1637