<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="stock_move_purchase" model="ir.ui.view">
            <field name="name">stock.move.form</field>
            <field name="model">stock.move</field>
            <field name="inherit_id" ref="stock.view_move_form"/>
            <field name="arch" type="xml">
                 <xpath expr="//group[@name='destination_grp']" position="inside">
                    <field name="purchase_line_id"/>
                </xpath>
            </field>
        </record>

        <record id="view_picking_in_search_picking_inherit" model="ir.ui.view">
            <field name="name">stock.picking.in.search.inherit</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_internal_search"/>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='product_id']" position="before">
                    <filter name="reception_to_invoice" string="Incoming Shipments to Invoice" domain="[('reception_to_invoice', '=', True), ('invoice_state', '!=', 'invoiced')]"/>
                </xpath>
            </field>
        </record>

        <!-- is it need ? we have another method "Receive Products"-->
        <record id="purchase_order_2_stock_picking" model="ir.ui.view">
            <field name="name">Purchase Picking Inherited</field>
            <field name="model">purchase.order</field>
            <field name="inherit_id" ref="purchase.purchase_order_form"/>
            <field name="arch" type="xml">
                 <xpath expr="//div[contains(@class, 'oe_title')]" position="before">
                    <div class="oe_right oe_button_box" name="buttons">
                        <button type="object"
                            name="view_picking"
                            class="oe_stat_button"
                            icon="fa-truck"
                            attrs="{'invisible': [('shipment_count', '=', 0)]}">
                            <field name="shipment_count" widget="statinfo" string="In Shipments" help="Incoming Shipments"/>
                        </button>
                        <button type="object"  name="invoice_open"
                            class="oe_stat_button"
                            icon="fa-pencil-square-o"
                            attrs="{'invisible': [('invoice_count', '=', 0)]}">
                            <field name="invoice_count" widget="statinfo" string="Invoices"/>
                        </button> 
                    </div>
                </xpath>
            </field>
        </record>
        
        <record id="view_warehouse_inherited" model="ir.ui.view">
            <field name="name">Stock Warehouse Inherited</field>
            <field name="model">stock.warehouse</field>
            <field name="inherit_id" ref="stock.view_warehouse"/>
            <field name="arch" type="xml">
                 <xpath expr="//field[@name='default_resupply_wh_id']" position="before">
                    <field name="buy_to_resupply" />
                </xpath>
            </field>
        </record>

        <record id="action_picking_tree_picking_to_invoice" model="ir.actions.act_window">
            <field name="name">On Incoming Shipments</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="context">{"default_type": "in", "contact_display": "partner_address", "search_default_done": 1, "search_default_reception_to_invoice": 1}</field>
            <field name="search_view_id" ref="stock.view_picking_internal_search"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create a new incoming shipment.
              </p><p> 
                Here you can track all the product receipts of purchase
                orders where the invoicing is "Based on Incoming Shipments",
                and for which you have not received a supplier invoice yet.
                You can generate a supplier invoice based on those receipts.
              </p>
            </field>
       </record>

        <menuitem action="action_picking_tree_picking_to_invoice"
            id="menu_action_picking_tree_picking_to_invoice"
            parent="purchase.menu_procurement_management_invoice" sequence="90"/>
    </data>
</openerp>
