<?xml version="1.0" encoding="utf-8"?>
<odoo>
        <record model="ir.actions.act_window" id="action_mrp_production_moves">
            <field name="name">Inventory Moves</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">stock.move.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">['|', ('move_id.raw_material_production_id', '=', active_id), ('move_id.production_id', '=', active_id)]</field>
        </record>

        <record id="view_stock_move_lots" model="ir.ui.view">
            <field name="name">stock.move.lots.form</field>
            <field name="model">stock.move</field>
            <field name="priority">1000</field>
            <field name="arch" type="xml">
                <form string="Lots">
                    <field name="state" invisible="1" force_save="1"/>
                    <group>
                        <group>
                            <field name="product_id" attrs="{'readonly': [('id', '!=', False)]}"/>
                            <label for="product_uom_qty"/>
                            <div class="o_row">
                                <span><field name="product_uom_qty" readonly="1" nolabel="1"/></span>
                                <span><field name="product_uom" readonly="1" force_save="1" nolabel="1"/></span>
                            </div>
                            <label for="quantity_done"/>
                            <div class="o_row">
                                <span><field name="quantity_done" attrs="{'readonly': ['|', ('is_locked', '=', True), '|', ('finished_lots_exist', '=', True), ('has_tracking', '!=', 'none')]}" nolabel="1"/></span>
                                <span> / </span>
                                <span><field name="reserved_availability" nolabel="1"/></span>
                                <!-- <span><field name="product_uom" readonly="1" nolabel="1"/></span>-->
                            </div>
                            <field name="is_done" invisible="1"/>
                            <field name="workorder_id" invisible="1"/>
                            <field name="location_id" invisible="1"/>
                            <field name="location_dest_id" invisible="1"/>
                            <field name="production_id" invisible="1"/>
                            <field name="raw_material_production_id" invisible="1"/>
                            <field name="is_locked" invisible="1"/>
                            <field name="name" invisible="1"/>
                            <field name="has_tracking" invisible="1"/>
                            <field name="order_finished_lot_ids" invisible="1"/>
                            <field name="finished_lots_exist" invisible="1"/>
                        </group>
                    </group>
                    <field name="active_move_line_ids" attrs="{'readonly': [('is_locked', '=', True)]}" context="{'default_workorder_id': workorder_id, 'default_product_uom_id': product_uom, 'default_product_id': product_id,  'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_production_id': production_id or raw_material_production_id}">
                        <tree editable="bottom" decoration-success="product_qty==qty_done" decoration-danger="(product_qty &gt; 0) and (qty_done&gt;product_qty)">
                            <field name="lot_id" attrs="{'column_invisible': [('parent.has_tracking', '=', 'none')]}" domain="[('product_id', '=', parent.product_id)]" context="{'default_product_id': parent.product_id}"/>
                            <field name="lot_produced_id" options="{'no_open': True, 'no_create': True}" domain="[('id', 'in', parent.order_finished_lot_ids)]" invisible="not context.get('final_lots')"/>
                            <field name="product_qty" string="Reserved" readonly="1"/>
                            <field name="qty_done"/>
                            <field name="workorder_id" invisible="1"/>
                            <field name="product_id" invisible="1"/>
                            <field name="product_uom_id" invisible="1"/>
                            <field name="location_id" invisible="1"/>
                            <field name="location_dest_id" invisible="1"/>
                            <field name="done_wo" invisible="1"/>
                            <field name="production_id" invisible="1"/>
                        </tree>
                    </field>
                </form>
            </field>
        </record>

        <record id="view_finisehd_move_line" model="ir.ui.view">
            <field name="name">mrp.finished.move.line.form</field>
            <field name="priority">1000</field>
            <field name="model">stock.move.line</field>
            <field name="arch" type="xml">
                <form string="Finished Product">
                    <group>
                        <group>
                            <field name="product_id" readonly="1"/>
                            <label for="qty_done" string ="Quantity"/>
                            <div class="o_row">
                                <span><field name="qty_done" readonly="1" nolabel="1"/></span>
                                <span>/</span>
                                <span><field name="product_uom_qty" readonly="1" nolabel="1"/></span>
                                <span><field name="product_uom_id" attrs="{'readonly': [('id', '!=', False)]}" nolabel="1"/></span>
                            </div>
                            <field name="lot_id" string="Lot/Serial number" groups="stock.group_production_lot" readonly="1" attrs="{'invisible': [('lots_visible', '=', False)]}"/>
                            <field name="lots_visible" invisible="1"/>
                        </group>
                    </group>
                </form>
            </field>
        </record>

    <menuitem id="menu_mrp_traceability"
          name="Lots/Serial Numbers"
          parent="menu_mrp_bom"
          action="stock.action_production_lot_form"
          groups="stock.group_production_lot"
          sequence="15"/>

    <menuitem id="menu_mrp_scrap"
            name="Scrap Orders"
            parent="menu_mrp_manufacturing"
            action="stock.action_stock_scrap"
            sequence="25"/>

</odoo>
