<?xml version="1.0" encoding="utf-8"?>
<odoo>

        <record id="view_mrp_product_produce_wizard" model="ir.ui.view">
            <field name="name">MRP Product Produce</field>
            <field name="model">mrp.product.produce</field>
            <field name="arch" type="xml">
                <form string="Produce">
                    <group>
                        <group>
                            <field name="serial" invisible="1"/>
                            <field name="production_id" invisible="1"/>
                            <field name="product_id" readonly="1"/>
                            <label for="product_qty"/>
                            <div class="o_row">
                                <field name="product_qty" attrs="{'readonly': [('serial', '=', True)]}"/>
                                <field name="product_uom_id" readonly="1" groups="uom.group_uom"/>
                            </div>
                            <field name="product_tracking" invisible="1"/>
                            <field name="lot_id" attrs="{'invisible': [('product_tracking', '=', 'none')], 'required': [('product_tracking', '!=', 'none')]}" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}"/>
                        </group>
                    </group>
                    <group>
                        <field name="produce_line_ids" attrs="{'invisible': [('produce_line_ids', '=', [])]}" nolabel="1" context="{'w_production': True, 'active_id': production_id, 'default_lot_id': lot_id}">
                            <tree editable="top" delete="0" decoration-danger="(qty_to_consume &lt; qty_done) or (qty_done &gt; qty_reserved)">
                                <field name="product_id" attrs="{'readonly': [('move_id', '!=', False)]}" required="1" domain="[('id', '!=', parent.product_id)]" force_save="1"/>
                                <field name="product_tracking" invisible="1"/>
                                <field name="lot_id" attrs="{'readonly': [('product_tracking', '=', 'none')]}" context="{'default_product_id': product_id}" domain="[('product_id', '=', product_id)]" groups="stock.group_production_lot"/>
                                <field name="qty_to_consume" readonly="1"/>
                                <field name="qty_reserved" readonly="1"/>
                                <field name="qty_done"/>
                                <field name="product_uom_id" readonly="1" force_save="1" groups="uom.group_uom"/>
                                <field name="move_id" invisible="1"/>
                            </tree>
                        </field>
                    </group>
                    <footer>
                        <button name="do_produce" type="object" string="Record Production" class="btn-primary"/>
                        <button string="Cancel" class="btn-secondary" special="cancel" />
                    </footer>
                </form>
            </field>
        </record>

        <record id="act_mrp_product_produce" model="ir.actions.act_window">
            <field name="name">Produce</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">mrp.product.produce</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="context">{}</field>
            <field name="target">new</field>
        </record>
</odoo>
