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.

0

How do I extend a view (specifically the warehouse/picking list) to add a button which launches a method?

By
E.M.
on 12/28/15, 7:54 AM 341 views

I want to create a new method to create a CSV with all picking items within a picking list.

I am specifically looking to understand how to extend a view by adding a button and associating that new method to it.

I am familiar with inheritance and module extension, I just never had to create a new button over an existing view.

1
Bernat Llibre
On 12/28/15, 8:04 AM

Here is an example:

I had to add a button in the orders view next to Reprint button.


View:

<openerp>
     <data>
         <record model="ir.ui.view" id="tpv_order_mail">
             <field name="name">pos.order.mail</field>
             <field name="model">pos.order</field>
             <field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>
             <field name="arch" type="xml">
                  <xpath expr="//field[@name='state']" position="before">
                         <button name="send_invoice" string="Send to..." type="object"/>
                  </xpath>

            </field>
        </record>
     </data>
</openerp>


The xpath is to select where the new element will be placed, so we tell the view to place the new button before the field named 'state'.


python:

We used an example to call the function of the new button:
@api.model
def send_invoice(self, context=None):
     return {
         'warning': {
            'title': "Toy op",

            'message': "Sepin el mandarin",
        }
    }


Hope this is useful.

Thanks this is really useful. However, I am trying to fully understand this part: pos.order.mail pos.order Could you please clarify what is used in each "id=" / name="name" and name="model" respectively? I feel like I do not fully understand what represents each field.

E.M.
on 1/5/16, 9:26 PM

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

1 follower(s)

Stats

Asked: 12/28/15, 7:54 AM
Seen: 341 times
Last updated: 1/5/16, 9:26 PM