<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="mrp_subcontracting_move_form_view" model="ir.ui.view">
        <field name="name">mrp.subcontracting.move.form.view</field>
        <field name="model">stock.move</field>
        <field name="priority">1000</field>
        <field name="arch" type="xml">
            <form create="0" delete="0">
                <sheet>
                    <field name="company_id" invisible="1"/>
                    <field name="product_id" invisible="1"/>
                    <field name="finished_lots_exist" invisible="1"/>
                    <field name="state" invisible="1"/>
                    <field name="move_line_ids" context="{'default_product_id': product_id}" attrs="{'readonly': [('state', 'in', ['done', 'cancel'])]}">
                        <tree editable="bottom" decoration-muted="state in ('done', 'cancel')">
                            <field name="state" invisible="1"/>
                            <field name="tracking" invisible="1"/>
                            <field name="product_id" readonly="1"/>
                            <field name="lot_produced_id"
                                context="{'default_product_id': parent.product_id}"
                                attrs="{'column_invisible': [('parent.finished_lots_exist', '!=', True)]}"
                            />
                            <field name="qty_done"/>
                            <field name="lot_id" context="{'default_product_id': product_id}"/>
                        </tree>
                    </field>
                </sheet>
            </form>
        </field>
    </record>

    <record id="mrp_subcontracting_move_tree_view" model="ir.ui.view">
        <field name="name">mrp.subcontracting.move.tree.view</field>
        <field name="model">stock.move</field>
        <field name="priority">1000</field>
        <field name="arch" type="xml">
            <tree create="0" delete="0" default_order="is_done,sequence" decoration-muted="is_done" decoration-warning="quantity_done&gt;product_uom_qty" decoration-success="not is_done and quantity_done==product_uom_qty" decoration-danger="not is_done and reserved_availability &lt; product_uom_qty">
                <field name="product_id" required="1"/>
                <field name="company_id" invisible="1"/>
                <field name="name" invisible="1"/>
                <field name="unit_factor" invisible="1"/>
                <field name="product_uom" groups="uom.group_uom"/>
                <field name="date" invisible="1"/>
                <field name="date_expected" invisible="1"/>
                <field name="picking_type_id" invisible="1"/>
                <field name="has_tracking" invisible="1"/>
                <field name="operation_id" invisible="1"/>
                <field name="needs_lots" readonly="1" groups="stock.group_production_lot"/>
                <field name="is_done" invisible="1"/>
                <field name="bom_line_id" invisible="1"/>
                <field name="sequence" invisible="1"/>
                <field name="location_id" invisible="1"/>
                <field name="warehouse_id" invisible="1"/>
                <field name="location_dest_id" domain="[('id', 'child_of', parent.location_dest_id)]" invisible="1"/>
                <field name="state" invisible="1" force_save="1"/>
                <field name="product_uom_qty" string="To Consume"/>
                <field name="reserved_availability" attrs="{'invisible': [('is_done', '=', True)], 'column_invisible': [('parent.state', 'in', ('draft', 'done'))]}" string="Reserved"/>
                <field name="quantity_done" string="Consumed" attrs="{'column_invisible': [('parent.state', '=', 'draft')]}" readonly="1"/>
            </tree>
        </field>
    </record>
</odoo>
