ODOO12如何呼叫客户动作

时间:2019-12-05 21:05:33

标签: javascript python-3.x xml odoo odoo-12

我试图调用带有一些JS函数的客户端操作,但是没有成功。

我的xml:

<data>
        <record id="some_client_action" model="ir.actions.client">
            <field name="name">check action</field>
            <field name="tag">tag_test_name</field>
        </record>

        <menuitem id="menu_test_id"
            name="Menu test"
            action="some_client_action"
            sequence="-100" groups="base.group_user"/>
    </data>

    <template id="some_template_id">
        <t t-name="SomeTemplate">
            <p>TEST</p>
        </t>
    </template>
odoo.define('my_module.my_js_file', function (require) {
    "use strict";

var AbstractAction = require('web.AbstractAction');
var rpc = require('web.rpc');
var core = require('web.core');

var Test_Client = AbstractAction.extend({
    template: 'SomeTemplate',

    init: function() {
        console.log("INIT FUNCTION")
    })
core.action_registry.add('tag_test_name', Test_Client);

return Test_Client;
});

但是,当我单击刚刚创建的新菜单时,就会显示休闲错误:

 Uncaught TypeError: Cannot read property 'on' of undefined
http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:3646
Traceback:
TypeError: Cannot read property 'on' of undefined
    at http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:3646:87
    at Function._.each._.forEach (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:12:558)
    at Class.on (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:3646:30)
    at Class._startController (http://localhost:8069/web/content/937-e8af9cf/web.assets_backend.js:485:322)
    at http://localhost:8069/web/content/937-e8af9cf/web.assets_backend.js:463:25
    at http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:802:681
    at fire (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:796:299)
    at Object.add [as done] (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:797:467)
    at Array.<anonymous> (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:802:649)
    at Function.each (http://localhost:8069/web/content/683-24d55fb/web.assets_common.js:62

控制台显示:INIT FUNCTION

有人知道如何加载模板? 我正在尝试加载模板,还使用rpc从python代码中获取了一些信息。我不想使用Qweb之类的东西带来这些信息,我需要使用JS。

0 个答案:

没有答案