Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3891 Vistas

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';

Avatar
Descartar
Mejor respuesta

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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 23
4738
0
oct 22
571
1
dic 23
1425
1
oct 23
3633
2
nov 22
12949