<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
	<!--
	Stock Picking Report
	-->

        <record id="view_report_report_stock_picking_tree" model="ir.ui.view">
            <field name="name">report.stock.picking.tree</field>
            <field name="model">report.stock.picking</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
               <tree string="Picking">
               		<field name="year" invisible="1"/>
               		<field name="month" invisible="1"/>
               		<field name="day" invisible="1"/>
               		<field name="date" invisible="1"/>
					<field name="company_id" invisible="1"/>
					<field name="partner_id" invisible="1"/>
					<field name="product_id" invisible="1"/>
					<field name="min_date" invisible="1"/>
					<field name="order_date" invisible="1"/>
					<field name="date_done" invisible="1"/>
					<field name="max_date" invisible="1"/>
					<field name="type" invisible="1"/>
					<field name="invoice_state" invisible="1"/>
					<field name="state" invisible="1"/>
					<field name="nbr" sum="# of Lines" />
					<field name="product_qty" sum="# of Products" />
          <field name="avg_days_to_deliver" avg='Avg Days to Deliver'/>
          <field name="avg_days_late" avg='Avg Due Days'/>
				</tree>
            </field>
        </record>

        <record id="view_report_report_stock_picking_graph" model="ir.ui.view">
            <field name="name">report.stock.picking.graph</field>
            <field name="model">report.stock.picking</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph orientation="horizontal" string="Picking" type="bar">
                    <field name="partner_id"/>
                    <field name="nbr" operator="+"/>
                    <field name="product_qty" operator="+"/>
                    <field name="nbp" operator="+"/>
                </graph>
            </field>
        </record>

		<record id="view_report_report_stock_picking_filter" model="ir.ui.view">
            <field name="name">report.stock.picking.select</field>
            <field name="model">report.stock.picking</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search">
                  <group col="16" colspan="6">
                   		<filter icon="terp-go-year" string="  365 Days  "
	                    	    domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
	                    	    help="Picking in last 365 days"/>
	                	<filter icon="terp-go-month" string="   30 Days   "
	                			name="month"
	                			domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
	                			help="Picking in last 30 days"/>
	                	<filter icon="terp-go-week"
                                string="    7 Days    "
                                separator="1"
                                domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
                                help="Picking during last 7 days"/>
                        <separator orientation="vertical"/>
                        <filter string="Todo" icon="terp-gtk-go-back-rtl" domain="[('state','in',('draft','auto','confirmed','assigned'))]"/>
                        <filter string="Done" icon="terp-dialog-close" domain="[('state','=','done')]"/>
                        <separator orientation="vertical"/>
                        <field name="partner_id"/>
                   </group>
                   <newline/>
                	<group expand="0" string="Extended Filters..." groups="base.group_extended">
                      <field name="product_id"/>
                      <separator orientation="vertical"/>
                      <field name="type"/>
	                    <field name="invoice_state"/>
                      <separator orientation="vertical"/>
                      <field name="company_id" groups="base.group_multi_company" widget="selection"/>
	                    <newline/>
	                    <field name="order_date"/>
	                    <field name="date_done"/>
                      <field name="min_date"/>
                      <field name="max_date"/>
                	</group>
                   <newline/>
                   <group expand="1" string="Group By...">
                        <filter string="Partner" name="Partner" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'product_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Shipping Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}"/>
                        <separator orientation="vertical"/>
                        <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                        <filter string="Invoice Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'invoice_state'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <separator orientation="vertical"/>
                        <filter string="Day" icon="terp-go-today" domain="[]" context="{'group_by':'day'}"/>
                        <filter string="Month" icon="terp-go-month" domain="[]" context="{'group_by':'month'}"/>
                        <filter string="Year" icon="terp-go-year" domain="[]" context="{'group_by':'year'}"/>
                    </group>
               </search>
            </field>
        </record>
        <record id="action_report_report_stock_picking" model="ir.actions.act_window">
            <field name="name">Picking</field>
            <field name="res_model">report.stock.picking</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
            <field name="view_id" ref="view_report_report_stock_picking_tree"/>
            <field name="search_view_id" ref="view_report_report_stock_picking_filter"/>
            <field name="context">{'search_default_Partner':1,'search_default_month':1,'group_by_no_leaf':1,'group_by':[]}</field>
        </record>

       	<record model="ir.actions.act_window.view" id="action_report_report_stock_picking_tree">
	        <field name="sequence" eval="1"/>
	        <field name="view_mode">tree</field>
	        <field name="view_id" ref="view_report_report_stock_picking_tree"/>
	        <field name="act_window_id" ref="action_report_report_stock_picking"/>
	    </record>

        <record model="ir.actions.act_window.view" id="action_report_report_stock_picking_graph">
	        <field name="sequence" eval="2"/>
	        <field name="view_mode">graph</field>
	        <field name="view_id" ref="view_report_report_stock_picking_graph"/>
	        <field name="act_window_id" ref="action_report_report_stock_picking"/>
	    </record>

        <menuitem name="Picking" action="action_report_report_stock_picking" 
                id="menu_report_report_stock_pickings_tree" parent="stock.next_id_61" sequence="5"/>

  </data>
</openerp>

