Odoo Help


How to open a form from a view button

on 11/29/13, 9:33 AM 7,915 views

I added a button to the sale order details tree view. When user hit the button I want to open the form view of the product.

<button name="action_link" string="" type="object" icon="gtk-go-forward"/>

in sale_order_line I put the action:

class sale_order_line(osv.osv):

    def action_link(self, cr, uid, ids, context=None):
        # return { ... to open the product form

It prints the id of the sale_order_line, but what must I return to open the product form in the client ?

Jaakko Komulainen
On 11/29/13, 10:14 AM

You need to change your button type to "action" , like its done in invoice form when opening a refund form:

 <button name="%(action_account_invoice_refund)d" type='action' string='Ask Refund' states='open,paid' groups="account.group_account_invoice"/>

and define the action in xml:

<record id="action_account_invoice_refund" model="ir.actions.act_window">
            <field name="name">Refund Invoice</field>
            <field name="res_model">account.invoice.refund</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
           <field name="view_id" ref="view_account_invoice_refund"/>
           <field name="target">new</field>

You can check the code example at addons/account/account_invoice_view.xml and addons/account/wizard/account_invoice_refund_view.xml

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: 11/29/13, 9:33 AM
Seen: 7915 times
Last updated: 7/28/15, 8:34 AM