<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="stock_picking_inherit_sale" model="ir.ui.view">
            <field name="name">stock.picking.form</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="stock.view_picking_form"/>
            <field name="arch" type="xml">
                <field name="auto_picking" position="after">
                    <field name="sale_id"/>
                </field>
            </field>
        </record>

        <record id="stock_move_sale" model="ir.ui.view">
            <field name="name">stock.move.form</field>
            <field name="model">stock.move</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="stock.view_move_form"/>
            <field name="arch" type="xml">
                 <xpath expr="/form/group/field[@name='tracking_id']"  position="before">
                    <field name="sale_line_id" colspan="2"/>
                </xpath>
            </field>
        </record>

        <!--
        <act_window
            domain="[('sale_id', '=', active_id)]"
            id="act_sale_order_2_stock_picking"
            name="Picking"
            res_model="stock.picking"
            src_model="sale.order"
            context="{'contact_display': 'partner'}" />

       <record id="action_sale_picking_out_tree_view" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="view_id" ref="stock.view_picking_out_tree"/>
            <field name="act_window_id" ref="act_sale_order_2_stock_picking"/>
        </record>

        <record id="action_sale_picking_out_form_view" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="stock.view_picking_out_form"/>
            <field name="act_window_id" ref="act_sale_order_2_stock_picking"/>
        </record>
        -->

        <!-- Adding Sales Order Reference to outgoing picking -->

        <record id="stock_picking_out_inherit_sale" model="ir.ui.view">
            <field name="name">Outgoing picking Inherited</field>
            <field name="model">stock.picking</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <field name="move_type" position="after">
                    <field name="sale_id"/>
                </field>
            </field>
        </record>

        <!--  Add menu: Billing - Deliveries to invoice -->
        <record id="outgoing_picking_list_to_invoice" model="ir.actions.act_window">
            <field name="name">Deliveries to Invoice</field>
            <field name="res_model">stock.picking</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar</field>
            <field name="domain">[('type','=','out')]</field>
            <field name="context">{'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1}</field>
            <field name="search_view_id" ref="stock.view_picking_out_search"/>
        </record>
        <menuitem action="outgoing_picking_list_to_invoice" id="menu_action_picking_list_to_invoice" parent="sale.menu_invoiced" groups="base.group_no_one" sequence="20"/>

    </data>
</openerp>
