Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

150
Vistas
Odoo 15 | act_window with useService Hook don't work in custom OWL component in setup method

I'm trying to register an act_window withing the setup method using the useService Hook, but it doesn't work.

This is my component.

    /** @odoo-module **/
    // const { useState, useRef } = owl.hooks;
    import { useEffect, useService } from "@web/core/utils/hooks";
    import AbstractField from 'web.AbstractFieldOwl'
    import { _lt } from 'web.translation';
    
    class ReferenceButtonWidget extends AbstractField {
    
      setup() {
        // super.setup(...arguments);
        this.actionService = useService('action')  // <----------------- ERROR
      }
    
      onClick() {
        console.log(this.value);
      }
    }
    
    ReferenceButtonWidget.description = _lt("Reference");
    ReferenceButtonWidget.supportedFieldTypes = ['reference'];
    ReferenceButtonWidget.template = 'iqba_document.reference_button_widget';
    
    
    const registry = require('web.field_registry_owl');
    
    registry.add('reference_button_widget', ReferenceButtonWidget)

If I comment the this.actionService = useService('action') line, my component renders ok.

If I pause the execution at that point, only these services are available:

browser debug console

What am I doing wrong? Thanks

For now I'm using this to call an action:

    this.__owl__.parent.parentWidget.do_action({
            type: 'ir.actions.act_window',
            res_model: this.value.model,
            res_id: this.value.res_id,
            views: [[false, 'form']],
            target: 'new'
          })

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.