<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!--
        Work Order Report
        -->
        <record id="view_report_mrp_workorder_graph" model="ir.ui.view">
            <field name="name">mrp.workorder.graph</field>
            <field name="model">mrp.workorder</field>
            <field name="arch" type="xml">
                <graph string="Work Orders" type="pivot">
                    <field name="workcenter_id" type="row"/>
                    <field name="date" interval="month" type="col"/>
                    <field name="product_qty" type="measure"/>
                    <field name="total_hours" type="measure"/>
                    <field name="total_cycles" type="measure"/>
                </graph>
            </field>
        </record>

        <!-- Custom reports (aka filters) -->
        <record id="filter_mrp_workorder_workload" model="ir.filters">
            <field name="name">Workload</field>
            <field name="model_id">mrp.workorder</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['workcenter_id'], 'col_group_by': ['date:month'], 'measures': ['total_hours', 'total_cycles']}</field>
        </record>
        <record id="filter_mrp_workorder_quantity_produced" model="ir.filters">
            <field name="name">Quantity Produced</field>
            <field name="model_id">mrp.workorder</field>
            <field name="domain">[('state','=','done')]</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['workcenter_id'], 'col_group_by': ['date:month'], 'measures': ['total_hours', 'total_cycles']}</field>
        </record>
        <record id="filter_mrp_workorder_current_production" model="ir.filters">
            <field name="name">Current Production</field>
            <field name="model_id">mrp.workorder</field>
            <field name="domain">[('state','=','startworking')]</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['workcenter_id'], 'col_group_by': ['product_id'], 'measures': ['product_qty', 'total_hours']}</field>
        </record>

        <record id="view_report_mrp_workorder_filter" model="ir.ui.view">
            <field name="name">mrp.workorder.select</field>
            <field name="model">mrp.workorder</field>
            <field name="arch" type="xml">
                <search string="Search">
                    <field name="date"/>
                    <filter string="Current" domain="[('state','not in',('draft','cancel','done'))]"/>
                    <filter string="Started" name="started" domain="[('state','=','startworking')]"/>
                    <filter string="Done" name="done" domain="[('state','=','done')]"/>
                    <field name="product_id" />
                    <field name="workcenter_id"/>
                    <group expand="1" string="Group By">
                        <filter string="Work Center" name="Workcenter" context="{'group_by':'workcenter_id'}" />
                        <filter string="Production" context="{'group_by':'production_id'}"/>
                        <filter string="Status" context="{'group_by':'state'}"/>
                        <filter string="Product" name="Product" context="{'group_by':'product_id'}" />
                        <separator/>
                        <filter string="Month Planned" name="terp-go-month" context="{'group_by':'date:month'}" help="Planned Month"/>
                    </group>
                </search>
            </field>
        </record>
        <record id="action_report_mrp_workorder" model="ir.actions.act_window">
            <field name="name">Work Order</field>
            <field name="res_model">mrp.workorder</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_report_mrp_workorder_graph"/>
            <field name="search_view_id" ref="view_report_mrp_workorder_filter"/>
            <field name="context">{'search_default_Workcenter': 1,'group_by_no_leaf':1,'group_by':[]}</field>
        </record>

        <record model="ir.actions.act_window.view" id="action_report_mrp_workorder_graph">
            <field name="sequence" eval="2"/>
            <field name="view_mode">graph</field>
            <field name="view_id" ref="view_report_mrp_workorder_graph"/>
            <field name="act_window_id" ref="action_report_mrp_workorder"/>
        </record>

        <menuitem name="Work Order Analysis" action="action_report_mrp_workorder" id="menu_report_mrp_workorders_tree" parent="mrp.next_id_77"/>

  </data>
</openerp>
