我仍然在学习如何正确添加自己的JavaScript代码。我试图将自己的东西添加到Odoo后端。Odoo10 Javascript Widget操作不工作:ClientWidget不是一个功能
我一直在仔细阅读“Building Interface Extensions”指南(https://www.odoo.com/documentation/10.0/howtos/web.html),但它严重不准确或完全过时。
看着像账户,项目Odoo正式模块后,CRM我编写这样的事:
odoo.define('rhp.main', function (require) {
"use strict";
var core = require('web.core');
var _t = core._t;
var _lt = core._lt;
var Widget = require('web.Widget');
var QWeb = core.qweb;
var Explorer = Widget.extend({
init: function(parent, options) {
console.log('Explorer inited');
},
start: function() {
console.log('Explorer started');
},
});
/* NONE OF THESE WORK OK */
//core.view_registry.add('exploreraction', Explorer);
//core.action_registry.add('exploreraction', function() { return new Explorer(); });
core.action_registry.add('exploreraction', 'rhp.main.Explorer');
//odoo.client_actions.add('exploreraction', Explorer);
/* "Main loaded" is successfully printed in console */
console.log("Main loaded");
return {
Explorer: Explorer,
};
});
我的模块XML数据:
<record id="explorer_action" model="ir.actions.client">
<field name="name">Document Explorer</field>
<field name="tag">exploreraction</field>
<field name="target">main</field>
</record>
<menuitem name="Documents" id="main_docs" />
<menuitem name="Document Explorer" id="rhp_explorer" parent="rhp.main_docs" action="rhp.explorer_action"/>
这是我最新的代码,当我点击菜单项没有任何反应,我得到这个弹出错误:
TypeError: ClientWidget is not a function
Traceback pas ted here https://pastebin.com/QLCaLwHC
=========================================
编辑:
我添加了模板,像维沙尔Khichadiya的例子:现在加入
<t t-name="exploreraction" >
<div id="exploreraction_div">
test
</div>
</t>
操作是这样的:
core.action_registry.add('exploreraction', Explorer);
现在,当我浏览到我的菜单项,现在我得到这个错误:
TypeError: this.__getterSetterInternalMap is undefined
新回溯这里:https://pastebin.com/phrqXFkz
我没有得到你想要什么? –
@VikiChavada我想创建一个JavaScript文件类似浏览器的界面,并将其用于Odoo后端。但基本上我的问题是,我所引用的官方文档(petstore)完全是假的,据我所知。 – user568021
无论如何,我会很高兴得到这样的OpenERP7视图/小部件/或Odoo10中的任何东西。见图:https://www.odoo.com/documentation/10.0/_images/qweb.png – user568021