This question has been flagged
3 Replies
18570 Views

I was trying to follow this guide of building a web-module: https://doc.openerp.com/trunk/web/module/

I created the following files according to guide:

// static/src/js/first_module.js
openerp.web_example = function (instance) {
    instance.web.client_actions.add('example.action', 'instance.web_example.action');
    instance.web_example.action = function (parent, action) {
        console.log("Executed the action", action);
    };
};

__openerp__.py

# __openerp__.py
{
    'name': "Web Example",
    'description': "Basic example of a (future) web module",
    'category': 'Hidden',
    'depends': ['web'],
    'data': ['web_example.xml'],
    'js': ['static/src/js/first_module.js'],
}

web_example.xml

<!-- web_example/web_example.xml -->
<openerp>
    <data>
        <record model="ir.actions.client" id="action_client_example">
            <field name="name">Example Client Action</field>
            <field name="tag">example.action</field>
        </record>
        <menuitem action="action_client_example"
                  id="menu_client_example"/>
    </data>
</openerp>

__init__.py is empty.

Now the "Example Client Action" link appears to the topbar of the admin-panel like it should but when I click it I get a notification saying "Could not find client action example.action"

I have checked my code few times to ensure it's similar to guide's. Am I just blind to some minor error, is there a misconception or what could be the problem?  Should there be something in the __init__.py file? If yes, then what? 

Avatar
Discard

same problem here! but in v7 the module works fine.

I had the same problem and I figured it out. I updated my old answer. I hope you find it helpful. If you like I can send you completed code.

Best Answer

After a couple of hours I found out the right solution:

Simple Solution:
Just download another example file from here: https://github.com/odoo/petstore (its for Odoo v8)
Documentation: http://odoo-80.readthedocs.org/en/latest/tutorials.html

Advanced Solution:
Remove from file __openerp__.py the following line:

'js': ['static/src/js/first_module.js']

And add the follwing lines in your web_example.xml file: (after <openerp><data> and before <record ...>

 <template id="assets_backend" name="web_example_assets" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/web_example/static/src/js/first_module.js"/>
            </xpath>
   </template>

So your link to js or css has to be linked in your xml file!

Avatar
Discard
Best Answer

ok, if you develop for Odoo, I think the problem is that the js files in the tutorial are included via the __openerp__py, but odoo needs them to include a

< script > tag 

with the js in your view xml file

Avatar
Discard
Best Answer

I have the same problem and I think it's because I'm using odoo 8 but the tutorial is for previous versions. Is there any documentation/tutorial on 8th version?

---

Update:

I had the exact same problem and finally I found out the problem is indentations. I was using notepad++ and sometimes I've copied lines of code from tutorial, sometimes I wrote code using keyboard, etc. aparantly I had the same indentation everywhere but in some lines of code I hade a couple of spaces and in some others I had tabs. Finaly I solved the problem with using the same indentation for the same groups of code.

I recently realized that notepad++ has helper lines for groups of code with same indentation and +/- signs to collapse/expand the code.

Avatar
Discard