تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2292 أدوات العرض

Hello, I'm trying to register a qweb template in odoo 16 but when I install and open the module this is the error I get
UncaughtPromiseError > KeyNotFoundError

Uncaught Promise > Cannot find owl.dashboard in this registry!

KeyNotFoundError: Cannot find owl.dashboard in this registry!
    at Registry.get (http://localhost:8069/web/assets/debug/web.assets_backend.js:14449:19) (/web/static/src/core/registry.js:74)
    at _executeClientAction (http://localhost:8069/web/assets/debug/web.assets_backend.js:60299:45) (/web/static/src/webclient/actions/action_service.js:975)
    at Object.doAction (http://localhost:8069/web/assets/debug/web.assets_backend.js:60560:24) (/web/static/src/webclient/actions/action_service.js:1236)
    at async Object.selectMenu (http://localhost:8069/web/assets/debug/web.assets_backend.js:62376:13) (/web/static/src/webclient/menus/menu_service.js:56)

This is my template

===
<?xml version="1.0" encoding="UTF-8"?><templates xml:space="preserve">    <t t-name="owl.OwlDashboard" owl="1">        <h1>Custom Dashboard</h1>    </t></templates>
===


This is the js controller that renders it 

===
odoo.define("owl_dashboard.OwlDashboard", function (require) {  "use strict";

  const { Component } = owl;  const actionRegistry = require("@web/webclient/actions/action_registry");

  class OwlDashboard extends Component {}

  OwlDashboard.template = "owl.OwlDashboard";

  // Register the action using actionRegistry directly  actionRegistry.add("owl.dashboard", OwlDashboard);

  return OwlDashboard;});

===
This is the menu


<?xml version="1.0" encoding="UTF-8"?><odoo>    <data>        <record id="action_owl_dashboard" model="ir.actions.client">            <field name="name">Dashboard</field>            <field name="tag">owl.dashboard</field>        </record>        <menuitem name="Owl Dashboard" id="menu_owl" sequence="12">            <menuitem name="Dashboard" id="menu_owl_dashboard" sequence="12"                action="action_owl_dashboard" />        </menuitem>    </data></odoo>
===
And I have them set in my manifest
    "depends": ["base", "web"],    "data": [        "views/dashboard.xml",    ],    "demo": [],    "installable": True,    "application": True,    "assets": {        "web.assets_backend": [            "owl/static/src/components/**/*.js",            "owl/static/src/components/**/*.xml",            "owl/static/src/components/**/*.scss",        ]    },

What am I missing to fix it

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

I managed to solve it, changed the js renderer and had to add  /** @odoo-module */

on top for it to become 
/** @odoo-module */

import { Component } from "@odoo/owl";import { registry } from "@web/core/registry";

class OwlDashboard extends Component {}OwlDashboard.template = "owl.OwlDashboard";

// Register the action using action registryconst actionRegistry = registry.category("actions");actionRegistry.add("owl.dashboard", OwlDashboard);

export default OwlDashboard;



الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 24
2924
1
يوليو 25
1667
1
مايو 25
999
1
مايو 25
1656
1
أبريل 25
2251