Search code examples
odoo

Place button in one2many field tree view


I want to add button in one2many tree view line. I have placed button in tree view and these button shows successfully.

But when i click on button, it display form define against one2many field instead of function call.

Need guidance how to call function/form on button click.

                    <page name="component_line_id" string="Component Lines">
                        <field name="component_line_id">
                            <tree>
                                <field name="purchase_order_id" required="1"/>
                                <field name="description"/>
                                <field name="payable_amount"/>
                                <field name="file_name" string="Attachment"/>
                                <button string="Create Bill" name="create_bill" type="object" class="oe_highlight" icon="fa-icon_you_like"/>
                                <button string="View Bill" name="view_bill" type="object" class="oe_highlight" icon="fa-icon_you_like"/>
                            </tree>
                            <form string="Component Lines">
                                <group>
                                    <group>
                                       <field name="purchase_order_id"/>
                                       <field name="description"/>
                                        <field name="payable_amount"/>
                                    </group>
                                    <group>
                                        <field name="attachment_file" filename="file_name"/>
                                        <field name="file_name" invisible="1"/>
                                    </group>
                                </group>
                            </form>
                        </field>
                    </page>

Solution

  • I think you need to save the record first to be able to run the button. Are you sure it was not on edit mode?