Odoo Help

Welcome!

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

1

How to open a form from a view button

By
peterm
on 11/29/13, 9:33 AM 4,545 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):
        print(ids) 
        # 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 ?

5
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>
</record>

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 11/29/13, 9:33 AM
Seen: 4545 times
Last updated: 7/28/15, 8:34 AM