我从github上获取了oepetstore代码,并对其进行了修改以适合odoo10,但是它给我的错误是Could not find client action 'petstore.homepage'。在清单文件中,我包含了所有xml文件。 github中提到的代码适用于odoo9,但不适用于10。

petstore.js,

odoo.define('oepetstore.petstore', function (require) {
"use strict";
    var Class = require('web.Class');
    var Widget = require('web.Widget');
    var core = require('web.core');
    var utils = require('web.utils');
    var _t = core._t;
    var _lt = core._lt;

    var homePage = Widget.extend({
        init: function(parent) {
            this._super(parent);
            console.log("Hello JS, I'm inside of init.");
        },
        start: function() {
            console.log("Your pet store home page loaded");
        },
    });
    core.view_registry.add('petstore', homePage);

});


petstore.xml,

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <data>
        <template id="assets_backend" name="petstore_assets" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <link rel="stylesheet" href="/oepetstore/static/src/css/petstore.css"/>
                <script type="text/javascript" src="/oepetstore/static/src/js/petstore.js"/>
            </xpath>
        </template>

        <menuitem id="main_petstore_menu" name="Pet Store" />

        <menuitem id="petstore_menu" name="Pet Store"
            parent="main_petstore_menu" />

        <record id="action_home_page" model="ir.actions.client">
            <field name="name">petstore</field>
            <field name="tag">petstore</field>
        </record>

        <menuitem id="home_page_petstore_menu" name="Home Page" parent="petstore_menu"
            action="action_home_page"/>
    </data>
</odoo>

最佳答案

您正在view_registry上注册小部件

core.view_registry.add('petstore', homePage);


尝试将其添加到action_registry上:

core.action_registry.add('petstore', homePage);


您可以在XML上看到正在执行的操作,而不是视图:

<record id="action_home_page" model="ir.actions.client">

09-11 18:30