Odoo Help


Start import from side menu

tim diamond
on 10/22/13, 4:14 PM 3,950 views

Hi community!

I'm curious if there is a way to start the import process from the side menu? For instance I havea an object called "Container".

I want to add an entry to the side menu that will take me directly to the "Import Container" screen, as opposed to clicking "Container", and then choosing the import link at the top of the screen.

Is this possible?

Sure, you could definitely hack something like that together, but I'd have to ask how that would be worth implementing. Are you really importing so frequently that the additional click is worth bypassing? If that's the case, maybe you should focus your efforts on automating the import rather than the click.

Brett Lehrer
on 10/22/13, 9:19 PM

I realize it seems odd, but its a customer request. The customer wishes to have this functionality. Could you possible explain a little more further what the "hack" would entail? I'm a very capable openerp programmer, I'm just not sure how to set up the action to do this.

tim diamond
on 10/23/13, 2:09 AM

Brett Lehrer

--Brett Lehrer--

| 5 5 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 10/23/13, 3:04 AM

It's actually much easier than I expected. You set up a client action with the tag 'import', and the params set to {'model': 'container.model'}. Then just make a standard menuitem and link to that action. This code completely covers it for events (randomly picked as an example):


<record id="event_import_action" model="ir.actions.client">
    <field name="name">Import Events</field>
    <field name="tag">import</field>
    <field name="params" eval="{'model': 'event.event'}"/>

<menuitem id="event_import_menu" action="event_import_action" parent="base.menu_event_main" sequence="16"/>


The end result is a traditional menuitem that opens the import menu for events: import_menu.jpg Just change around the menuitem location and model to your liking.

tim diamond
on 10/25/13, 3:29 PM

See my answer above for my code/error. (couldn't post code in commen).Could you test all the way through an import and see if you get the same error? No idea where to start debugging since there is no output to the log (looks like a javascript web error)

tim diamond
on 10/25/13, 3:37 PM
tim diamond
On 10/25/13, 3:34 PM

Thank you for your answer! Everything looks awesome, and it even validates, however when I try to hit Import, I get this screen that says: "Uncaught an exception occurred in a caller-provided callback function". And nothing in the log file. Code:

    <record id="event_import_products" model="ir.actions.client">
            <field name="name">Ingreso de Notas de Pedido</field>
            <field name="tag">import</field>
            <field name="params" eval="{'model': 'product.product'}"/>

    <menuitem id="ingresos_mend" action = "event_import_products" parent="menu_purchase_container" name="Ingreso de Notas de Pedido" />

The import I need to do is a product import, thats why I have product.product (I was wrong, its not a container import).

Importing products is tricky, due to the product.template framework left in place for product variants. I don't know if that's actually playing a part here though. I'll have to look at that some more to replicate that error.

Brett Lehrer
on 10/25/13, 10:28 PM

Been debugging today. I set a break point and actually, the import goes through perfect despite the error. It looks like the error has to due with the fact that post-import, the program is trying to redirect somewhere, and its not finding where... Also, if you hit the cancel button while going to this screen through the new menu, the program also errors. But just to be clear: this does result in a sucessful import, just not a correct redirect. Any idea what I could do to eliminate this error?

tim diamond
on 10/25/13, 10:52 PM

The error is in the javascript, and only appears after a successful import. I believe all that is left for the process to do at that point is to reload the page. If you go into the module base_import and look for the file base_import/static/src/js/import.js, on line 394 change "tag: 'history_back'" to "tag: 'reload'" and that error goes away. Don't know how to make that a simple inherited fix though. Basically the JS needs to respond two different ways depending on where you came from, the menuitem or the traditional import method.

Brett Lehrer
on 10/26/13, 3:18 AM

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 10/22/13, 4:14 PM
Seen: 3950 times
Last updated: 3/16/15, 8:10 AM