2
votes

I took the oepetstore code from github and modified it to suit odoo10 however it is giving me error as Could not find client action 'petstore.homepage'. In the manifest file I have included all the xml files. code mentioned in github works for odoo9 but not for 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>
2

2 Answers

4
votes

You are registering the widget on the view_registry

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

Try to add it on the action_registry:

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

You can see on your XML that your are expecting an action, and not a view:

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

On xml

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

on js instead of add view add action

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

also odoo.define(module_name.js_file_name, .....)