<?xml version="1.0"?>
<openerp>
<data>

    <record model="ir.ui.view" id="mrp_production_workcenter_tree_view_inherit">
        <field name="name">mrp.production.workcenter.line.tree</field>
        <field name="model">mrp.production.workcenter.line</field>
        <field name="type">tree</field>
        <field name="inherit_id" eval="False"/>
        <field name="arch" type="xml">
            <tree string="Work Orders">
                <field name="production_id"/>
                <field name="date_planned"/>
                <field name="product"/>
                <field name="qty"/>
                <field name="uom"/>
                <field name="name"/>
                <field name="workcenter_id"/>
                <field name="cycle"/>
                <field name="hour"/>
                <field name="state" />
                <button name="button_start_working" string="Start working" states="draft,pause"/>
                <button name="button_done" string="Finished" states="startworking"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="mrp_production_workcenter_form_view_inherit">
        <field name="name">mrp.production.workcenter.line.form</field>
        <field name="model">mrp.production.workcenter.line</field>
        <field name="type">form</field>
        <field name="inherit_id" eval="False"/>
        <field name="arch" type="xml">
            <form string="Work Orders">
                <group col="6" colspan="4">
                    <field colspan="4" name="name" select="1"/>
                    <field name="workcenter_id" select="1"/>
                    <field name="production_id"/>
                    <field name="production_state"/>
                    <field name="sequence"/>
                </group>
                <notebook colspan="4">
                <page string="Information">
                    <group colspan="2" col="2">
                        <separator string="Planned Date" colspan="2"/>
                        <field name="date_planned"/>
                        <field name="date_planned_end"/>
                    </group>

                    <group colspan="2" col="2">
                        <separator string="Duration" colspan="2"/>
                        <field name="cycle"/>
                        <field name="hour" widget="float_time"/>
                    </group>

                    <group colspan="2" col="2">
                        <separator string="Real" colspan="2"/>
                        <field name="date_start" readonly="1"/>
                        <field name="date_finnished" readonly="1"/>
                        <field name="delay" widget="float_time"/>
                    </group>
                    <group colspan="2" col="2">
                        <separator string="Product to Produce" colspan="2"/>
                        <field name="product"/>
                        <field name="qty"/>
                        <field name="uom"/>
                    </group>

                    <separator string="Status" colspan="4"/>
                    <group colspan="8" col="8">
                        <field name="state" select="2"/>
                        <button name="button_draft" string="Set Draft" states="cancel"/>
                        <button name="button_start_working" string="Start" states="draft"/>
                        <button name="button_resume" string="Resume" states="pause"/>
                        <button name="button_cancel" string="Cancel" states="draft,startworking"/>
                        <button name="button_pause" string="Pause" states="startworking"/>
                        <button name="button_done" string="Finished" states="startworking"/>
                    </group>
                </page>
                </notebook>
            </form>
        </field>
    </record>

    <record id="workcenter_line_calendar" model="ir.ui.view">
        <field name="name">mrp.production.workcenter.line.calendar</field>
        <field name="model">mrp.production.workcenter.line</field>
        <field name="type">calendar</field>
        <field name="arch" type="xml">
            <calendar color="product" date_stop="date_finnished" date_start="date_start" string="Operations">
                <field name="workcenter_id"/>
                <field name="production_id"/>
            </calendar>
        </field>
    </record>


    <record id="workcenter_line_gantt" model="ir.ui.view">
        <field name="name">mrp.production.workcenter.line.gantt</field>
        <field name="model">mrp.production.workcenter.line</field>
        <field name="type">gantt</field>
        <field name="arch" type="xml">
            <gantt color="production_id" date_stop="date_planned_end" date_start="date_planned" string="Operations">
                <level object="mrp.workcenter" link="workcenter_id" domain="[]">
                    <field name="product"/>
                    <field name="production_id"/>
                </level>
            </gantt>
        </field>
    </record>


    <!-- Action for tree view of workcenter line   -->

    <record model="ir.actions.act_window" id="mrp_production_wc_action_form">
        <field name="name">Work Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.production.workcenter.line</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,gantt,calendar,graph</field>
        <field name="domain">[('id','=',active_id)]</field>
    </record>

    <!-- Action for All Operations   -->

    <record model="ir.actions.act_window" id="mrp_production_wc_action">
        <field name="name">All Work Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.production.workcenter.line</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,graph,calendar,gantt</field>
    </record>


    <record model="ir.actions.act_window" id="mrp_production_wc_action_planning">
        <field name="name">Work Orders Planning</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.production.workcenter.line</field>
        <field name="view_type">form</field>
        <field name="domain">[('production_state','in',('ready','confirmed','in_production'))]</field>
        <field name="view_mode">gantt,tree,form,graph,calendar</field>
    </record>


    <!-- Action for Confirm Operations   -->

    <record model="ir.actions.act_window" id="mrp_production_wc_confirm_action">
        <field name="name">Confirmed Work Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.production.workcenter.line</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,graph,gantt,calendar</field>
        <field name="domain">[('production_state','=','ready')]</field>
    </record>

    <!-- Action for Draft Operations   -->

    <record model="ir.actions.act_window" id="mrp_production_wc_draft_action">
        <field name="name">Future Work Orders</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp.production.workcenter.line</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form,graph</field>
        <field name="domain">[('state','=','draft')]</field>
    </record>

    <record model="ir.values" id="mrp_production_wc_action_open">
        <field name="key2" eval="'tree_but_open'"/>
        <field name="model" eval="'mrp.production.workcenter.line'"/>
        <field name="name">Work Orders</field>
        <field name="value" eval="'ir.actions.act_window,'+str(mrp_production_wc_action_form)"/>
        <field name="object" eval="True"/>

    </record>

    <menuitem name="All Work Orders" parent="mrp.menu_mrp_root" id="menu_mrp_production_wc_action" action="mrp_production_wc_action"/>
    <menuitem name="Work Orders to Do" parent="menu_mrp_production_wc_action" action="mrp_production_wc_confirm_action" id="menu_mrp_production_wc_confirm_action"/>
    <menuitem name="Future Work Orders" parent="menu_mrp_production_wc_action" action="mrp_production_wc_draft_action" id="menu_mrp_production_wc_draft_action"/>
    <menuitem parent="menu_mrp_production_wc_action" action="mrp_production_wc_action_planning" id="menu_mrp_production_wc_draft_action_planning"/>

<!-- Operation codes -->

    <record model="ir.ui.view" id="mrp_production_code_tree_view">
        <field name="name">mrp.production.code.tree</field>
        <field name="model">mrp_operations.operation.code</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Production Operation Code">
                <field name="name" select="1"/>
                <field name="code" select="1"/>
                <field name="start_stop" select="1"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="mrp_production_code_form_view">
        <field name="name">mrp.production.code.form</field>
        <field name="model">mrp_operations.operation.code</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Production Operation Code">
                <field name="name" select="1"/>
                <field name="code" select="1"/>
                <field name="start_stop" select="1"/>
            </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="mrp_production_code_action">
        <field name="name">Operations Code</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp_operations.operation.code</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="mrp_production_code_tree_view"/>
    </record>

    <menuitem name="Start - Stop Codes" parent="mrp.menu_mrp_configuration" id="menu_mrp_production_code_action" action="mrp_production_code_action"/>

<!-- Operations -->

    <record model="ir.ui.view" id="mrp_production_operation_tree_view">
        <field name="name">mrp.production.operation.tree</field>
        <field name="model">mrp_operations.operation</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Production Operation" editable="top">
                <field name="production_id"/>
                <field name="workcenter_id"/>
                <field name="code_id"/>
                <field name="date_start"/>
                <field name="date_finished"/>
                <field name="order_date"/>
            </tree>
        </field>
    </record>

     <record id="graph_in_hrs_workcenter" model="ir.ui.view">
            <field name="name">graph.in.hrs.workcenter</field>
            <field name="model">mrp.production.workcenter.line</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Hours by Workcenter" type="bar">
                     <field name="date_start_date"/>
                     <field name="hour" operator="+"/>
                     <field name="workcenter_id" group="True" operator="+"/>
                </graph>
            </field>
        </record>



    <!--<record model="ir.ui.view" id="mrp_production_operation_form_view">
        <field name="name">mrp.production.operation.form</field>
        <field name="model">mrp_operations.operation</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Production Operation">
                <field name="production_id" select="1"/>
                <field name="workcenter_id" select="1"/>
                <field name="code_id" select="1"/>
            </form>
        </field>
    </record>
-->
    <record model="ir.actions.act_window" id="mrp_production_operation_action">
        <field name="name">Operations</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">mrp_operations.operation</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,calendar,form</field>
        <field name="view_id" ref="mrp_production_operation_tree_view"/>
    </record>

    <menuitem
        name="Work Order Events Using Bar Codes"
        parent="mrp.menu_mrp_root"
        id="menu_mrp_production_operation_action"
        action="mrp_production_operation_action"/>

    <record id="mrp_production_reorder_form_view" model="ir.ui.view">
        <field name="name">mrp.production.allow_reorder.form</field>
        <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
        <field name="model">mrp.production</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <field name="priority" position="after">
                <field name="allow_reorder"/>
            </field>
        </field>
    </record>

    <record model="ir.ui.view" id="operation_calendar_view">
            <field name="name">mrp.perations.calendar</field>
            <field name="model">mrp_operations.operation</field>
            <field name="type">calendar</field>
            <field name="priority" eval="2"/>
            <field name="arch" type="xml">
                <calendar string="Calendar View" date_start="order_date" color="workcenter_id">
                    <field name="date_start"/>
                    <field name="date_finished"/>
                </calendar>
            </field>
    </record>

</data>
</openerp>
