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

        <record id="view_report_mrp_production_order_tree" model="ir.ui.view">
            <field name="name">mrp.production.order.tree</field>
            <field name="model">mrp.production.order</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
               <tree colors="blue:state in ('draft');black:state in ('picking_except','confirmed','ready','in_production');gray:state in ('done','cancel') " string="Production">
                      <field name="date_planned"/>
                      <field name="bom_id" invisible="1"/>
                      <field name="product_id" invisible="1"/>
                      <field name="product_qty" sum='Product Qty'/>
                      <field name="nbr" string="#Line Orders" sum='#Line Orders'/>
                      <field name="state" invisible="1"/>
                      <field name="picking_id" invisible="1"/>
                      <field name="priority" invisible="1"/>
                      <field name="day" invisible="1" />
                      <field name="month" invisible="1" />
                      <field name="year" invisible="1" />
                      <field name="location_src_id" invisible="1"/>
                      <field name="location_dest_id" invisible="1"/>
                      <field name="company_id" groups="base.group_multi_company" invisible="1"/>
				</tree>
            </field>
        </record>

        <record id="view_report_mrp_production_order_graph" model="ir.ui.view">
            <field name="name">mrp.production.order.graph</field>
            <field name="model">mrp.production.order</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph orientation="horizontal" string="Production" type="bar">
                    <field name="state"/>
                    <field name="nbr" operator="+"/>
                </graph>
            </field>
        </record>

		<record id="view_report_mrp_production_order_filter" model="ir.ui.view">
            <field name="name">mrp.production.order.select</field>
            <field name="model">mrp.production.order</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="Year"
	                    	    domain="[('year','=',time.strftime('%%Y'))]"
	                    	    help="Production performed during current year"/>
	                    <filter icon="terp-go-month" string="Month"
	                    		name="month"
	                    		domain="[('date','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
	                    		help="Production performed during current month"/>
		                <filter icon="terp-go-week"
	                            string="Month -1"
	                            separator="1"
	                            domain="[('date','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
	                            help="Production during last month"/>
                      <separator orientation="vertical"/>
                        <filter string="Current" icon="terp-check" domain="[('state','in',('open','draft'))]"/>
                        <filter icon="terp-check" string="In Production" domain="[('state','=','in_production')]"/>
                        <filter icon="terp-dialog-close" string="Done" domain="[('state','=','done')]"/>
                      <separator orientation="vertical"/>
                        <field name="location_src_id" />
                        <field name="location_dest_id" />
                   </group>
                   <newline/>
                    <group expand="0" string="Extended Filters..." groups="base.group_extended">
                        <filter icon="terp-emblem-important" string="Picking Exception" domain="[('state','=','picking_except')]"/>
                        <filter icon="terp-gtk-media-pause" string="Waiting Goods" domain="[('state','=','confirmed')]"/>
                        <filter icon="terp-camera_test" string="Ready to Produce" domain="[('state','=','ready')]"/>
                        <separator orientation="vertical"/>
                      <field name="priority"/>
                      <separator orientation="vertical"/>
                      <field name="company_id" groups="base.group_multi_company"/>
                      <newline/>
                        <field name="date_start"/>
                      <field name="date_planned"/>
                      <field name="date_finished"/>
                    </group>
                   <newline/>
                   <group expand="1" string="Group By...">
                    	<filter string="Raw Material Location" icon="terp-gtk-jump-to-rtl" context="{'group_by':'location_src_id'}"/>
                    	<filter string="Finished Products Location" icon="terp-gtk-jump-to-ltr" context="{'group_by':'location_dest_id'}"/>
                    	<separator orientation="vertical"/>
                        <filter string="Product" name="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}" />
                    	<filter string="BOM" icon="terp-mrp" context="{'group_by':'bom_id'}"/>
                    	<separator orientation="vertical"/>
                        <filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    	<separator orientation="vertical"/>
                    	<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                    	<separator orientation="vertical" groups="base.group_multi_company"/>
                        <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/>
                    	<separator orientation="vertical"/>
                    	<filter string="Month" name="terp-go-month" icon="terp-go-month" context="{'group_by':'month'}"/>
                    	<separator orientation="vertical"/>
                    	<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
                   </group>
                  </search>
            </field>
        </record>
        <record id="action_report_mrp_production_order" model="ir.actions.act_window">
            <field name="name">Production Analysis</field>
            <field name="res_model">mrp.production.order</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
            <field name="view_id" ref="view_report_mrp_production_order_tree"/>
            <field name="search_view_id" ref="view_report_mrp_production_order_filter"/>
            <field name="context">{'search_default_Product': 1,'search_default_month':1,'group_by_no_leaf':1,'group_by':[]}</field>
            <field name="help">This reporting allows you to analyse your manufacturing activities and performance.</field>
        </record>

       	<record model="ir.actions.act_window.view" id="action_report_mrp_production_order_tree">
	        <field name="sequence" eval="1"/>
	        <field name="view_mode">tree</field>
	        <field name="view_id" ref="view_report_mrp_production_order_tree"/>
	        <field name="act_window_id" ref="action_report_mrp_production_order"/>
	    </record>

        <record model="ir.actions.act_window.view" id="action_report_mrp_production_order_graph">
	        <field name="sequence" eval="2"/>
	        <field name="view_mode">graph</field>
	        <field name="view_id" ref="view_report_mrp_production_order_graph"/>
	        <field name="act_window_id" ref="action_report_mrp_production_order"/>
	    </record>

        <menuitem name="Production Analysis" action="action_report_mrp_production_order" id="menu_report_mrp_production_orders_tree" parent="next_id_77"/>

  </data>
</openerp>

