Tumetsu
Tumetsu

Reputation: 1721

Could not find client action (openERP 8/Odoo)

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?

Upvotes: 0

Views: 3792

Answers (3)

Ibtissem
Ibtissem

Reputation: 51

In v8 adding of static files is different as v7. You must define static files in view, where you inheriting core views. 1. in module folder create folder named views 2. create in where file named: you_module_name.xml 3. in openerp.py add: 'data': ['views/you_module_name.xml'] 4. in you_module_name.xml add:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <template id="assets_backend" name="you_module_name assets" inherit_id="web.assets_backend">
        <xpath expr="." position="inside">
            <link rel="stylesheet" href="/you_module_name/static/src/css/you_module_name.css"/>
            <script type="text/javascript" src="/you_module_name/static/src/js/you_module_name.js"></script>
        </xpath>
    </template>
</data>

Upvotes: 4

vimesh chaudhari
vimesh chaudhari

Reputation: 31

if you haven't find any way, then please follow below step for OpenERP8/odoo. Add below contain in your web_example module.

web_example

└── views

  └──document.xml

In document.xml add below contain.

<data>
    <template id="web_example_assets_backend" name="web_example assets" inherit_id="web.assets_backend">`enter code here`
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/web_example/static/src/js/first_module.js"></script>
        </xpath>
    </template>
</data>

Now,modify openerp.py

openerp.py

{

'name': "Web Example",
'description': "Basic example of a (future) web module",
'category': 'Hidden',
'depends': ['web'],
'data': ['web_example.xml','views/document.xml'],

}

Thats it. now,your js file is loaded in v8/odoo. :)

same way you can add your css file in document.xml

Thank You.

Upvotes: 3

Filipe Castanheira
Filipe Castanheira

Reputation: 632

I am taking my first steps into biulding a web client, and just tried this tutorial yesterday. So I'm not sure my answer is right, but, is the name of your module "web_example"? If not, you should instantiate it with the name of your module in your js file. (it's working for me and got through the tutorial and got the timer working).

Good luck!

Upvotes: 0

Related Questions