我从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>
答案 0 :(得分:4)
您正在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">
答案 1 :(得分:1)
在xml上
<record id="action_home_page" model="ir.actions.client">
<field name="name">Pet Store Home</field>
<field name="tag">petstore</field>
</record>
在js而不是添加视图添加操作
core.action_registry.add('petstore', homePage);
还有odoo.define(module_name.js_file_name,.....)