<?xml version="1.0"?>
<form string="Repair Order">
                <field name="has_uncomplete_moves" invisible="1"/>
                <field name="unreserve_visible" invisible="1"/>
                <field name="reserve_visible" invisible="1"/>
               <header>
                   <button name="action_validate" invisible="state != 'draft'" type="object" string="Confirm Repair" class="oe_highlight" data-hotkey="v"/>
                   <button name="action_repair_start" invisible="state != 'confirmed'" type="object" string="Start Repair" class="oe_highlight" data-hotkey="q"/>
                   <button name="action_repair_end" invisible="state != 'under_repair' or not has_uncomplete_moves" type="object" string="End Repair" class="oe_highlight" data-hotkey="x" confirm="For some of the parts, there is a difference between the initial demand and the actual quantity that was used. Are you sure you want to confirm ?"/>
                   <button name="action_repair_end" invisible="state != 'under_repair' or has_uncomplete_moves" type="object" string="End Repair" class="oe_highlight" data-hotkey="x"/>
                   <button name="action_assign" invisible="not reserve_visible" string="Check availability" type="object"/>
                   <button name="action_unreserve" type="object" string="Unreserve" invisible="not unreserve_visible" data-hotkey="w"/>
                   <button name="action_create_sale_order" type="object" string="Create Quotation" invisible="state == 'cancel' or sale_order_id"/>
                   <button name="action_repair_cancel" string="Cancel Repair" type="object" invisible="state in ('done', 'cancel')" data-hotkey="l"/>
                   <button name="action_repair_cancel_draft" invisible="state != 'cancel'" string="Set to Draft" type="object" data-hotkey="z"/>
                   <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,under_repair,done"/>
               </header>
               <sheet string="Repairs order">
                    <div class="oe_button_box" name="button_box">
                        <!-- No groups attribute on the next button as "stock.group_stock_user" is needed for Repair, and as this group is granted 'sale.order' read/write accesses in sale_stock module (forcefully loaded as transitive dependency) -->
                        <button name="action_view_sale_order" type="object" string="Sale Order" icon="fa-dollar" class="oe_stat_button" invisible="not sale_order_id">
                            <div class="o_field_widget o_stat_info">
                                <span class="o_stat_value">
                                    <field name="sale_order_id" widget="statinfo" nolabel="1" class="mr4"/>
                                </span>
                                <span class="o_stat_text">Sale Order</span>
                            </div>
                        </button>
                        <button name="660" type="action" string="Product Moves" class="oe_stat_button" icon="fa-exchange" invisible="state not in ['done', 'cancel']"/>
                    </div>
                    <div class="oe_title">
                        <label class="o_form_label" for="name"/>
                        <h1 class="d-flex">
                            <field name="priority" widget="priority" class="me-3"/>
                            <field name="name"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="allowed_lot_ids" invisible="1"/>
                            <field name="repair_request" invisible="not sale_order_line_id"/>
                            <field name="partner_id" widget="res_partner_many2one" context="{'res_partner_search_mode': 'customer', 'show_vat': True}" readonly="sale_order_id"/>
                            <field name="product_id" readonly="state in ['cancel', 'done']"/>
                            <field name="lot_id" context="{'default_product_id': product_id}" groups="stock.group_production_lot" options="{'no_create': True, 'no_create_edit': True}" invisible="tracking not in ['serial', 'lot']" readonly="state == 'done'" required="tracking in ['serial', 'lot']"/>
                            <field name="product_uom_category_id" invisible="1"/>
                            <label for="product_qty" invisible="not product_id"/>
                            <div class="o_row" invisible="not product_id">
                                <field name="product_qty" readonly="tracking == 'serial' or state in ('done', 'cancel')"/>
                                <field name="product_uom" groups="uom.group_uom" readonly="state != 'draft'"/>
                            </div>
                            <field name="picking_id" options="{'no_create': True}"/>
                            <field name="under_warranty" readonly="state in ['cancel', 'done']"/>
                        </group>
                        <group>
                            <field name="schedule_date" readonly="state in ['done', 'cancel']"/>
                            <field name="user_id" domain="[('share', '=', False)]"/>
                            <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
                            <field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
                            <field name="parts_availability_state" invisible="True"/>
                            <field name="parts_availability" invisible="state not in ['confirmed', 'under_repair']" decoration-success="parts_availability_state == 'available'" decoration-warning="parts_availability_state == 'expected'" decoration-danger="parts_availability_state == 'late'"/>
                        </group>
                        <field name="repair_properties" nolabel="1" columns="2" hideAddButton="1"/>
                    </group>
                <notebook>
                    <page string="Parts" name="parts">
                        <field name="move_ids" readonly="state == 'cancel' or state == 'done'" context="{'default_repair_id': id, 'default_product_uom_qty': 1, 'default_company_id': company_id, 'default_date': schedule_date, 'default_repair_line_type': 'add'}">
                            <list string="Operations" editable="bottom">
                                <control>
                                    <create string="Add a line"/>
                                    <button name="action_add_from_catalog_repair" string="Catalog" type="object" class="px-4 btn-link" context="{'order_id': parent.id}"/>
                                </control>
                                <field name="company_id" column_invisible="True"/>
                                <field name="name" column_invisible="True"/>
                                <field name="state" column_invisible="True"/>
                                <field name="repair_line_type" required="1"/>
                                <field name="picking_type_id" column_invisible="True"/>
                                <field name="location_id" column_invisible="True"/>
                                <field name="location_dest_id" column_invisible="True"/>
                                <field name="partner_id" column_invisible="True" readonly="state == 'done'"/>
                                <field name="scrapped" column_invisible="True"/>
                                <field name="picking_code" column_invisible="True"/>
                                <field name="show_details_visible" column_invisible="True"/>
                                <field name="additional" column_invisible="True"/>
                                <field name="move_lines_count" column_invisible="True"/>
                                <field name="is_locked" column_invisible="True"/>
                                <field name="product_uom_category_id" column_invisible="True"/>
                                <field name="is_storable" column_invisible="True"/>
                                <field name="has_tracking" column_invisible="True"/>
                                <field name="display_assign_serial" column_invisible="True"/>
                                <field name="product_id" context="{'default_is_storable': True}" required="1" readonly="(state != 'draft' and not additional) or move_lines_count &gt; 0"/>
                                <field name="description_picking" string="Description" optional="hide"/>
                                <field name="date" optional="hide"/>
                                <field name="date_deadline" optional="hide"/>
                                <field name="product_packaging_id" groups="product.group_stock_packaging"/>
                                <field name="product_uom_qty" string="Demand" readonly="state in ('done', 'cancel')"/>
                                <field name="forecast_expected_date" column_invisible="True"/>
                                <button type="object" name="action_product_forecast_report" title="Forecast Report" icon="fa-area-chart" column_invisible="parent.state != 'draft'" invisible="forecast_availability &lt; 0 and repair_line_type == 'add'"/>
                                <button type="object" name="action_product_forecast_report" title="Forecast Report" icon="fa-area-chart text-danger" column_invisible="parent.state != 'draft'" invisible="forecast_availability &gt;= 0 or repair_line_type != 'add'"/>
                                <field name="forecast_availability" string="Forecasted" column_invisible="parent.state in ('draft', 'done')" widget="forecast_widget"/>
                                <field name="product_qty" readonly="1" column_invisible="True"/>
                                <field name="quantity" string="Done" readonly="not product_id"/>
                                <field name="product_uom" readonly="state != 'draft' and not additional" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="uom.group_uom"/>
                                <field name="picked" string="Used"/>
                                <field name="lot_ids" widget="many2many_tags" groups="stock.group_production_lot" invisible="not show_details_visible or has_tracking != 'serial'" optional="hide" context="{'default_product_id': product_id}" domain="[('product_id','=',product_id)]" readonly="not id"/>
                                <button name="action_show_details" type="object" icon="fa-list" width="0.1" title="Details" invisible="not show_details_visible" options="{&quot;warn&quot;: true}" context="{'default_location_dest_id': location_dest_id}"/>
                            </list>
                        </field>
                        <div class="clearfix"/>
                    </page>
                    <page string="Repair Notes" name="repair_notes">
                        <field name="internal_notes" placeholder="Add internal notes."/>
                    </page>
                    <page string="Miscellaneous" name="page_miscellaneous">
                        <group>
                            <field name="picking_type_id" options="{'no_create': True}" readonly="state in ('done', 'cancel')"/>
                        </group>
                        <group string="Locations" groups="stock.group_stock_multi_locations" name="locations">
                            <field name="product_location_src_id" readonly="state != 'draft'" options="{'no_create': True}"/>
                            <field name="location_id" readonly="state != 'draft'" options="{'no_create': True}"/>
                        </group>
                    </page>
                </notebook>
                </sheet>
                <chatter/>
            </form>
        