Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to put something in the up menu v7 ?

By
Anabela Damas
on 2/18/15, 2:09 PM 556 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. 

0
Shawn Varghese
On 2/19/15, 3:34 AM

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.

 

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

Versão Integral, Anabela Damas
on 2/19/15, 4:10 AM

You are using version 7 right?

Shawn Varghese
on 2/19/15, 5:19 AM

yes

Versão Integral, Anabela Damas
on 2/19/15, 5:57 AM

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 ?

Versão Integral, Anabela Damas
on 2/19/15, 6:29 AM

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

Versão Integral, Anabela Damas
on 2/23/15, 6:11 AM

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

Versão Integral, Anabela Damas
on 3/13/15, 3:03 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/18/15, 2:09 PM
Seen: 556 times
Last updated: 3/16/15, 8:10 AM