Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open particular object from button or menu

Tags:

openerp

How can one open a particular object when pressing on a menu item or a button? It's useful if you want to have a sort a configuration-like object (only one object is needed to hold data e.g. username and password).

I've tried playing with view_init method and active_id context key, but with no luck. Can somebody point me to the right direction?

like image 650
and3p Avatar asked Jan 16 '23 20:01

and3p


1 Answers

I had a similar issue, and found a solution : in your ir.actions.act_window definition (in XML), try to add the res_id field with the id of your record you want to show. If this is id is calculated, perhaps you can use the "eval" attribute of the same field to get it.

For example :

<field name="res_id">5</field>

Or (i don't know if it works)

<field name="res_id" eval="your_func_getting_res_id"/>

Of course for 2nd method, don't forget to define your function.

It works for me when i wanted to return an ir.actions.act_window in a method called by a button (method defined in python, so i got easily the id i wanted).

Hope it helps you or someone else.

like image 74
nonow_dev Avatar answered Jan 27 '23 11:01

nonow_dev