Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
4003 Представления

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
4961
0
окт. 22
571
1
дек. 23
1576
1
окт. 23
3836
2
нояб. 22
13107