Skip to Content
Menu
This question has been flagged
1 Reply
3601 Views

Hello, 

I wanted to put something near the name of the user in the upper menu, rigtth coner.

I try to do this :  http://lolierp.blogspot.pt/2014/11/odoo-8-heritage-de-javascript-ex.html

But nothing happend, I don't know if it is the version... 

Then I made some changes in __openerp__.py:

I tryed like this :

'js': ["static/src/js/mydisplaydb.js"],
'qweb' : ["static/src/xml/mydisplaydb.xml"],

than like this:

'data': [],
'js': ["static/src/js/mydisplaydb.js"],
'qweb' : [],

And I change the the mydisplaydb.xml, because I was getting an error:

<template id="assets_backend" name="change_bar" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/vi_change_bar/static/src/js/mydisplaydb.js"></script>
</xpath>
</template>

 

Still nothing. 

I wanted to put there a float returned by a function, for the user to know is balance.

I'm not familiar to JS. 

Avatar
Discard
Best Answer

If you are using OpenERP version 7, try this way of including JS files.

In the _openerp_.py part in the link, look for this part:

'data': ['mydisplaydb.xml'],
'js': [],

Put the name of the js file here (mydisplaydb.js), and replace the xml file call for data so it should look like this:

'data': [],
'js': [mydisplaydb.js],

So basically, instead of using the XML file and calling the JS file from there, you can directly link it in the _openerp_.py manifest file.

I used to use this method to call JS files in OpenERP 7. Also, can you give an idea of what you are looking to put in the top right corner? We can explain what is necessary in the JS file more clearly.

Let me know if you need more help with this.

Edit:

Ok. Now, remove the xml file completely. In version 7, you do not require the XML for JS. Only keep your JS file and write only the following in your JS file. Your __openerp___.py manifest file must only keep the JS file as a dependency, there should be not xml mentioned in it.

openerp.mydisplaydb = function (instance)

{

instance.web.UserMenu.include(
    {
        do_update: function ()
        {
            this._super();
            alert("hello");
        }
    });

}

Do not keep anything else in your JS file. Refresh your browser and see if you can get an alert. Please note, in the first line, openerp.mydisplaydb, the name must exactly match the name of your module.

If this doesn't work, we'll go step by step and start over.

 

Avatar
Discard
Author

I'm going to change my question to put code, it stays better. =)

You are using version 7 right?

Author

yes

Author

Thanksssss a LOT. The problem was " Please note, in the first line, openerp.mydisplaydb, the name must exactly match the name of your module." . Wish me luck to put there my float value , I already have the "hello" =) . Do you know how to put something (a word) in the letf of the envelope ?

Author

Thanks!! I write the value like this : this.get_value_balance(self.session.uid, function(res) { el_html.text(_.str.sprintf("Saldo: %s", res)); });

Author

Hi, now I'm trying to do the same in v8, do you know what are the changes? I made the same test with the alert(); and it's not call ....

Related Posts Replies Views Activity
3
Dec 21
9253
0
Mar 15
6507
2
Mar 15
5697
2
Apr 25
5921
0
Dec 24
9442