<openerp>
    <data>
        <record id="view_picking_wave_form" model="ir.ui.view">
            <field name="name">picking.wave.form</field>
            <field name="model">stock.picking.wave</field>
            <field name="arch" type="xml">
                <form string="Stock Picking Waves">
                    <header>
                        <button name="confirm_picking" states="draft" string="Confirm" type="object" class="oe_highlight"/>
                        <button name="done" states="in_progress" string="Done" type="object" class="oe_highlight"/>
                        <button name="cancel_picking" string="Cancel" type="object" states="in_progress"/>
                        <field name="state" widget="statusbar" statusbar_visible="in_progress,done"/>
                    </header>
                    <sheet>
                        <div class="oe_right oe_button_box">
                            <button name="print_picking" string="Print all pickings" type="object"/>
                        </div>
                        <div class="oe_title">
                            <h1>
                                <field name="name" class="oe_inline" readonly="1"/>
                            </h1>
                        </div>
                        <group>
                            <field name="user_id"/>
                        </group>
                        <separator string="Pickings"/>
                        <field name="picking_ids" widget="many2many" domain="[('state', 'not in', ('done', 'cancel'))]">
                            <tree>
                                <field name="name"/>
                                <field name="backorder_id"/>
                                <field name="origin"/>
                                <field name="date"/>
                                <field name="min_date"/>
                                <field name="state"/>
                                <button name="action_assign" string="Confirm picking" type="object" icon="gtk-apply" attrs="{'invisible': [('state', 'in', ('done', 'cancel', 'confirmed', 'assigned'))]}"/>
                                <button name="force_assign" string="Force availability" type="object" icon="gtk-go-forward" attrs="{'invisible': [('state', 'in', ('done', 'cancel', 'draft', 'assigned'))]}"/>
                                <button name="action_cancel" string="Cancel picking" type="object" icon="gtk-cancel" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}"/>
                            </tree>
                        </field>
                    </sheet>
                </form>
            </field>
        </record>


        <record id="view_picking_wave_tree" model="ir.ui.view">
            <field name="name">picking.wave.tree</field>
            <field name="model">stock.picking.wave</field>
            <field name="arch" type="xml">
                <tree string="Stock Picking Waves" colors="black:state in ('in_progress','done');grey: state=='cancel'">
                    <field name="name"/>
                    <field name="user_id"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <record id="view_picking_wave_filter" model="ir.ui.view">
            <field name="name">picking.wave.filter</field>
            <field name="model">stock.picking.wave</field>
            <field name="arch" type="xml">
                <search string="Search Picking Waves">
                    <field name="name" string="Picking Wave"/>
                    <filter name="in_progress" string="In Progress" domain="[('state','=', 'in_progress')]" help="Picking Waves not finished"/>
                    <field name="user_id"/>
                    <group expand="0" string="Group By">
                        <filter string="User" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="State" domain="[]" context="{'group_by':'state'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record id="action_picking_wave" model="ir.actions.act_window">
            <field name="name">Picking Waves</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">stock.picking.wave</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{"search_default_in_progress" : True,}</field>
            <field name="search_view_id" ref="view_picking_wave_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create a Picking Wave. 
              </p><p>
                The Goal of the picking waves is to group operations that may 
                (needs to) be done together in order to increase their efficiency.
                It may also be useful to assign jobs (one person = one wave) or
                help the timing management of operations (tasks to be done at 1pm).
              </p>
            </field>
        </record>
        <menuitem action="action_picking_wave" id="menu_action_picking_wave" parent="stock.menu_stock_warehouse_mgmt" sequence="30"/>

        <record model="ir.ui.view" id="view_stock_picking_wave_inherit">
        <field name="name">stock.picking.wave.inherit.form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='picking_type_id']" position="after">
                <field name="wave_id" domain="[('state', 'not in', ('done', 'cancel'))]"/>
            </xpath>
        </field>
        </record>
        <record model="ir.ui.view" id="view_stock_picking_wave_tree_inherit">
        <field name="name">stock.picking.wave.inherit.tree</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.vpicktree"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='picking_type_id']" position="after">
                <field name="wave_id"/>
            </xpath>
        </field>
        </record>
        <record model="ir.ui.view" id="view_stock_picking_wave_search_inherit">
        <field name="name">stock.picking.wave.inherit.search</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_internal_search"/>
        <field name="arch" type="xml">
            <xpath expr="//filter[@string='Picking Type']" position="after">
                <filter string="Wave" domain="[]" context="{'group_by':'wave_id'}"/>
            </xpath>
        </field>
        </record>

    </data>
</openerp>
