Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3989 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 23
4957
0
ต.ค. 22
571
1
ธ.ค. 23
1570
1
ต.ค. 23
3832
2
พ.ย. 22
13094