在Odoo中替换插件的JS文件

时间:2018-01-30 17:03:46

标签: xml odoo odoo-9

我想在Odoo 9中替换一个JS文件。

这是位于 web_editor / views / editor.xml 中的 web_editor 插件中的原始 xml 文件:

editor.xml (原创)

<openerp>
    <template id="editor" name="Editor">
        ...
        <script type="text/javascript" src="/web_editor/static/src/js/transcoder.js"></script>
        ...
    </template>
</openerp>

我用我的JS文件和这个xml视图创建了一个模块(addon_extra):

editor.xml (自定义)

<openerp>
    <template id="web_editor.editor" name="Editor">
        ...
        <script type="text/javascript" src="/my_module/static/src/js/transcoder.js"></script>
        ....
    </template>
</openerp>

__的OpenERP __吡啶

# -*- coding: utf-8 -*-
{
    'name': 'My Module',
    'version': '1.0',
    'category': 'web',
    'depends': ['web_editor'],
    'data': ['views/editor.xml'],
    'demo': [],
    'test': [],
    'installable': True,
    'application': False,
    'auto_install': False,
}

但这并不奏效。当我尝试安装它时,会出现错误:

Uncaught Error: Widget type 'html' is not implemented
http://myserver:8069/web/static/src/js/views/form_view.js:1331
Traceback:
Error: Widget type 'html' is not implemented
    at http://myserver:8069/web/static/src/js/views/form_view.js:1331:23
    at Function._.each._.forEach (http://myserver:8069/web/static/lib/underscore/underscore.js:145:9)
    at Class.render_to (http://myserver:8069/web/static/src/js/views/form_view.js:1324:11)
    at Class.load_form (http://myserver:8069/web/static/src/js/views/form_view.js:138:31)
    at Class.view_loading (http://myserver:8069/web/static/src/js/views/form_view.js:107:21)
    at Object.<anonymous> (http://myserver:8069/web/static/src/js/framework/view.js:65:32)
    at Object.<anonymous> (http://myserver:8069/web/static/lib/jquery/jquery.js:3276:89)
    at fire (http://myserver:8069/web/static/lib/jquery/jquery.js:3119:58)
    at Object.fireWith [as resolveWith] (http://myserver:8069/web/static/lib/jquery/jquery.js:3231:49)
    at Object.deferred.(anonymous function) [as resolve] (http://myserver:8069/web/static/lib/jquery/jquery.js:332

2 个答案:

答案 0 :(得分:2)

您可以使用xpath表达式将文件替换为您的文件。

<openerp>
    <template id="editor_inherit" inherit_id="web_editor.editor" name="web_editor inherited editor">
        <xpath expr="//script[@src='/web_editor/static/src/js/transcoder.js']" position="replace">
            <!-- Your module Js File -->
        </xpath>
    </template>
</openerp>

答案 1 :(得分:0)

您可以尝试这样的事情:

<openerp>
    <template inherit_id="web_editor.editor" name="Editor">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/my_module/static/src/js/transcoder.js"></script>
        </xpath>
    </template>
</openerp>

我希望这对你有所帮助。