<?xml version="1.0" ?>
<odoo>
    <record id="mrp_production_serial_matrix_view_form" model="ir.ui.view">
        <field name="name">mrp.production.serial.matrix.form</field>
        <field name="model">mrp.production.serial.matrix</field>
        <field name="arch" type="xml">
            <form>
                <group>
                    <group name="info">
                        <field name="production_id" options='{"no_open": True}' />
                        <field name="product_id" options='{"no_open": True}' />
                        <field
                            name="company_id"
                            options='{"no_open": True}'
                            invisible="1"
                        />
                    </group>
                    <group name="settings">
                        <field name="include_lots" widget="boolean_toggle" />
                    </group>
                </group>
                <group name="finished_lots" string="Finished Product Serial Numbers">
                    <p
                        class="oe_grey"
                        colspan="2"
                    >Select the Serial Numbers of the Finished Products that are going to be produced in this MO. You can create new ones on the fly if needed.</p>
                    <br />
                    <field
                        name="finished_lot_ids"
                        widget="many2many_tags"
                        context="{'default_product_id': product_id, 'default_company_id': company_id}"
                    />
                </group>
                <group
                    name="serial_matrix"
                    string="Components Lot/Serial Numbers Matrix"
                >
                    <p
                        class="oe_grey"
                        colspan="2"
                    >Fill each cell with the lot/serial number consumed to produce each finished product serial number</p>
                    <br />
                    <field
                        name="line_ids"
                        nolabel="1"
                        widget="x2many_2d_matrix"
                        field_x_axis="component_column_name"
                        field_y_axis="finished_lot_name"
                        field_value="component_lot_id"
                        colspan="2"
                    >
                        <tree editable="True" nolabel="1" create="false">
                            <field name="component_column_name" />
                            <field name="finished_lot_name" />
                            <field
                                name="component_lot_id"
                                options='{"no_create": True}'
                            />
                            <field name="component_id" invisible="1" />
                            <field name="lot_qty" invisible="1" />
                            <field name="finished_lot_id" invisible="1" />
                            <field name="allowed_component_lot_ids" invisible="1" />
                        </tree>
                    </field>
                    <div
                        class="alert alert-warning text-center"
                        role="alert"
                        attrs="{'invisible': [('lot_selection_warning_count', '=', 0)]}"
                        style="margin-bottom:0px;"
                    >
                        <p><i
                                class="fa fa-info-circle"
                            /> Some issues has been detected in your selection:
                            <br />
                            <field name="lot_selection_warning_msg" nolabel="1" />
                            <field name="lot_selection_warning_count" invisible="1" />
                        </p>
                    </div>
                </group>
                <footer>
                    <button
                        name="button_validate"
                        string="Validate"
                        type="object"
                        class="oe_highlight"
                    />
                    <button string="Cancel" class="oe_link" special="cancel" />
                </footer>
            </form>
        </field>
    </record>

    <record id="action_mrp_production_serial_matrix" model="ir.actions.act_window">
        <field name="name">Serial Numbers and Lot Consumption Matrix</field>
        <field name="res_model">mrp.production.serial.matrix</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>

</odoo>
