Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
1 Responder
1805 Visualizações

I have a following function inside JS:

onClickRecruitmentRequest() {
var self = this;
self.do_action({
type: 'ir.actions.act_window',
res_model: 'my.model',
name: 'Request',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
res_id: false,
});
}

it is called from template on click of the button but it reveals mistake:
TypeError: self.do_action is not a function at PivotRenderer.onClickRecruitmentRequest (http://127.0.0.1:8069/web/assets/1052-b013586/web.assets_backend.min.js:11991:103) at extra.handlers. (eval at _compile (http://127.0.0.1:8069/web/assets/897-cf7c985/web.assets_common.min.js:1014:178), :176:183) at invokeHandler (http://127.0.0.1:8069/web/assets/897-cf7c985/web.assets_common.min.js:838:144) at handleEvent (http://127.0.0.1:8069/web/assets/897-cf7c985/web.assets_common.min.js:842:92) at HTMLElement.handler (http://127.0.0.1:8069/web/assets/897-cf7c985/web.assets_common.min.js:844:58)

Avatar
Cancelar
Melhor resposta

Hi,

Try like below code

import { useService } from "@web/core/utils/hooks";

// Add action service to the PivotRenderer


setup(){
this.super()
this.action = useService("action")
},
onClickRecruitmentRequest() {
var self = this;
self.action.doAction({
type: 'ir.actions.act_window',
res_model: 'my.model',
name: 'Request',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
res_id: false,
});
}

Regards

Avatar
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
jun. 23
1856
1
out. 22
3919
0
mai. 20
3055
2
jan. 20
8540
1
mar. 15
6070