0
votes

In my form view each record should have an icon with a redirection to a specific website. For Example:

Record 1 | www.test.com/a

Record 2 | www.test.com/b

How is it possible to create such a redirection on click?

I tried a button - but I dont know how to redirect in the action:

<form string="MyForm">
                <sheet>
                    <group>
                          <page string="MyPage">
                                <field name="MyRecords" widget="one2many_list">
                                    <tree string="Records">
                                        <field name="identifier"/>
                                        <field name="recordname"/>
                                        <button type="object" name="open_record_action" icon="fa-external-link" />
                                    </tree>
                                </field>
                            </page>
                            <page>
                            ...
                            </page>
                    </group>
                    <group>
                    ...
                    </group>
                </sheet>

In the model:

@api.multi
    def open_record_action(self, context):
        ????

Also a possible solution would be to store the link in a field in the model and to implement it in the view in this way:

<field name="url" widget="url"/>

But with this solution the link is displayed. But I want only to see the icon.

Any ideas how to solve?

1
What are you using? What is <sheet>, <page>, <tree>, etc. ?grochmal
Sheet is the "sheet" of the view. Page is in a way a tab (you can switch between different tabs in the view). Tree is just a summary of the fields. Aren't this just standard odoo terms?sampa
Oh cool, sorry for my lack of knowledge there. I've suggested a retag to use odoo/openerp instead of hyperlink. People with that specific knowledge will be able to find the question easier.grochmal

1 Answers

7
votes

You can use "ir.actions.act_url":

return {
    'type': 'ir.actions.act_url',
    'url': '/forum/%s/question/%s' % (self.forum_id.id, self.id),
    'target': 'self',
    'res_id': self.id,
}

Check website_forum/models/forum.py for instance.