コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3980 ビュー

Hi i am trying to render a component in a button click. I created a template and a component. But i don't know how link the button action and the component. Please guide.

Here is the code.

Buttonclick.js

          odoo.define('mobile_basket_verification.basket_menu', function (require) {
"use strict";

const MainMenu = require('stock_barcode.MainMenu').MainMenu;

MainMenu.include({
events: Object.assign({}, MainMenu.prototype.events, {

'click .basket_verification_line': function () {
this.do_action('mobile_basket_verification.BasketVerificationComponent');
},

}),
});
});
            
template.xml











Component.js

/** @odoo-module **/

const { Component } = owl;
const { useSubEnv, useState } = owl.hooks;

class BasketVerificationComponent extends Component{

}

BasketVerificationComponent.template = 'mobile_basket_verification.basket_verification';

アバター
破棄
最善の回答

Hi,

Try like below code

odoo.define('mobile_basket_verification.basket_menu', function (require) {
"use strict";

const MainMenu = require('stock_barcode.MainMenu').MainMenu;
const { Component } = owl;
const { useSubEnv, useState } = owl.hooks;

class BasketVerificationComponent extends Component{
_mount(){
this.mount(document.body)
}
}

BasketVerificationComponent.template = 'mobile_basket_verification.basket_verification';

MainMenu.include({
events: Object.assign({}, MainMenu.prototype.events, {
'click .basket_verification_line': function () {
var basketVerification = new BasketVerificationComponent()
basketVerification._mount();
},
}),
});
});

Regards

アバター
破棄
関連投稿 返信 ビュー 活動
1
9月 23
4955
0
10月 22
571
1
12月 23
1564
1
10月 23
3831
2
11月 22
13091