<openerp>
   <data> 
   
     <!-- picking by journal and invoice's tree view-->

        <record model="ir.ui.view" id="view_sale_journal_picking_report_tree">
            <field name="name">sale.journal.picking.report.tree</field>
            <field name="model">sale.journal.picking.report</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Picking Journal">
                    <field name="name" invisible="1"/>
                    <field name="month" invisible="1"/>
                    <field name="invoice_state" invisible="1"/>
                    <field name="state" invisible="1"/>
                    <field name="invoice_type_id" invisible="1"/>
                    <field name="journal_id" invisible="1"/>
                    <field name="quantity" />
                    <field name="count" />
                    <field name="price_average"/>
                    <field name="price_total"/>
                </tree>
            </field>
        </record>

        <!-- picking journal's graph view -->

        <record id="view_sale_journal_picking_graph" model="ir.ui.view">
            <field name="name">sale.journal.picking.report.graph</field>
            <field name="model">sale.journal.picking.report</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
               <graph string="Picking journal Statistics" type="bar">
                 <field name="journal_id"/>
                 <field name="invoice_type_id"/>
                 <field name="price_total"/>
              </graph>
           </field>
       </record>

       <!-- Picking journal search view -->

        <record model="ir.ui.view" id="view_sale_journal_picking_report_search">
            <field name="name">sale.journal.picking.report.search</field>
            <field name="model">sale.journal.picking.report</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Picking journal">
                    <group col="8" colspan="4">
                        <filter icon="terp-go-year" string="This Year" name="year" domain="[('name','=',time.strftime('%%Y'))]" help="Picking by invoice or by journal method in this year"/>
                        <filter icon="terp-go-month" string="This Month" name="month" domain="[('month','=',time.strftime('%%m'))]" help="Picking by invoice or by journal method in this month"/>
                        <separator orientation="vertical"/>
                        <filter icon="terp-document-new"
                                string="Draft"
                                domain="[('state','=','draft')]"/>
                        <filter icon="terp-gtk-media-pause"
                                string="Pending"
                                domain="[('state','=','waiting')]"/>
                        <filter icon="terp-camera_test"
                                string="Confirmed"
                                domain="[('state','=','confirmed')]"/>
                        <separator orientation="vertical"/>
                        <field name="name" select="1"/>
                        <field name="month" select="1"/>
                        <field name="invoice_state" select="1"/>
                        <field name="state" select="1"/>
                    </group>
                    <newline/>
                    <group expand="1" string="Group By..." colspan="4" col="12">
                        <filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
                        <filter string="Invoice" icon="terp-dolar" context="{'group_by':'invoice_type_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Invoice state" icon="terp-stock_effects-object-colorize" context="{'group_by':'invoice_state'}"/>
                        <filter string="state" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_sale_journal_picking_report_open">
            <field name="name">Statistics on picking to invoice</field>
            <field name="res_model">sale.journal.picking.report</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('invoice_state','=','2binvoiced'),('invoice_type_id','=',active_id)]</field>
        </record>

    <!-- Action for picking journal view -->

        <record model="ir.actions.act_window" id="action_sale_journal_picking_report_open_menu_all">
            <field name="name">Picking Journal</field>
            <field name="res_model">sale.journal.picking.report</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
            <field name="search_view_id" ref="view_sale_journal_picking_report_search"/>
            <field name="context">{'search_default_month':1, 'group_by_no_leaf':1,'group_by':[]}</field>
        </record>

        <menuitem name="Picking journal" id="menu_invoice_type_picking_stats_open_all" parent="stock.next_id_61" 
                  action="action_sale_journal_picking_report_open_menu_all" sequence="8"/>

    </data>
</openerp>
