1
votes

I want to replace a JS file in Odoo 9.

This is the original xml file in the web_editor addon located in web_editor/views/editor.xml:

editor.xml (original)

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

I have created a module (addon_extra) with my JS file and this xml view:

editor.xml (custom)

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

__openerp__.py:

# -*- 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,
}

But that doesn't work. When I try to install it, an error appears:

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
In your xml editor.xml did you add xpath expression?Juan Salcedo
@JuanSalcedo, no. Do I need to add xpath?MouTio

2 Answers

2
votes

You can replace file with your file using xpath expression.

<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>
0
votes

You can try something like this:

<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>

I hope this can be helpful for you.