Odoo Help

1

Open record in new tab

By
Lucio
on 3/1/13, 11:03 AM 4,192 views

When checking a tree view I want to be able to double click in a record and open the form view in a new tab.

Let's assume my model is something like:

class new_model(osv.osv):
    _name= model.name
    ...
new_model()

I tried this but it is not working!

<record id="action_view_model_new_tab" model="ir.actions.act_window">
  <field name="name">Open New Tab</field>
  <field name="type>ir.actions.act_window</field>
  <field name="res_model>model.name</field>
  <field name="view_type">form</field>
  <field name="view_mode">tree,form</field>
</record>
<record id="ir_open_model_new_tab" model="ir.values">
  <field name="key2">tree_but_open</field>
  <field name="model">model.name</field>
  <field name="name">Open in New Tab</field>
  <field name="value" eval="'ir.actions.act_window,+str(ref(action_view_model_new_tab))/>
  <field name="object>True</field>
</record>

ADDED INFO:

I also tried doing this:

<record id="action_view_model_tree" model="ir.actions.act_window">
  <field name="name">Open Tree View</field>
  <field name="type>ir.actions.act_window</field>
  <field name="res_model>model.name</field>
  <field name="view_type">form</field>
  <field name="view_mode">tree</field>
</record>
<record id="action_view_model_new_tab" model="ir.actions.act_window">
  <field name="name">Open New Tab</field>
  <field name="type>ir.actions.act_window</field>
  <field name="res_model>model.name</field>
  <field name="view_type">form</field>
  <field name="view_mode">form</field>
  <field name="target">new</field>
</record>
<record id="ir_open_model_new_tab" model="ir.values">
  <field name="key2">tree_but_open</field>
  <field name="model">model.name</field>
  <field name="name">Open in New Tab</field>
  <field name="value" eval="'ir.actions.act_window,+str(ref(action_view_model_new_tab))/>
  <field name="object>True</field>
</record>

Assuming that there is a way to open the tree view (e.g. a menu item or something else). But doing this, has the effect that the double click causes a refresh of the tree view and nothing else. And also, the form button is not clickable.

Hi, thanks for th vote and edited answer for url, but now I have a bug on my rights to mark my answer as correct, see : http://help.openerp.com/question/4051/bug-on-this-forum-right-lost-for-function-mark-after-moderation-of-a-user-answer/

Cyril Gaspard (GEM)
on 3/2/13, 10:29 AM
0
Ray Carnes
On 5/7/17, 10:18 PM

Create a button that calls an action like this (v10):


WWW = the model/document you want to open

XXX = the menu you want to call

YYY = the action that you want to call

ZZZ = the human readable name of the model/document


Hint: Check the URL that is shown when you open the model/document in the existing tab to see the values for XXX, YYY and ZZZ.


@api.multi

        def action_open_new_tab(self):
                for rec in self:
                        base_url = self.env['ir.config_parameter'].get_param('web.base.url')
                        record_url = base_url + "/web#id=" + str(self.id) + "&view_type=form&model=WWW&menu_id=XXX&action=YYY"
                client_action = {
                        'type': 'ir.actions.act_url',
                        'name': "ZZZ",
                        'target': 'new',
                        'url': record_url,
                }
                return client_action
3
Cyril Gaspard (GEM)
On 3/1/13, 11:30 PM

Hi,

in an action definition, target set to new open the view in a new window :

<field name="target">new</field>

but this is for the action which dispaly the view tree or form.

I think you should add a button in tree line which will open a new window using a function.

you have an example here which open an url but to modify naturally (add the beginning of url h t t p : / /, I can't add actually link url because I have not enaugh Karma):

http://forum.openerp.com/forum/topic29798.html

Bye

Thank for your answer. I am aware of the use of target>new. Moreover, I tried doing what I added to my question but it does not work either! It seems then, that it is not possible to do what I want? Open with the double click a new window/tab? I do not like adding a button to the view just for this! Anyway, thanks again for the answer!

Lucio
on 3/4/13, 12:06 PM

Hi, I think to do what you want you should be obliged to create a new type of tree view in web module ..., or try to overwrite action which open the form, but I don't no where. If somebody knows ... Bye

Cyril Gaspard (GEM)
on 3/4/13, 3:34 PM

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.

Register

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)

Stats

Asked: 3/1/13, 11:03 AM
Seen: 4192 times
Last updated: 5/7/17, 10:18 PM