<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 2024-2026 Nexa Systems Inc.
    License OPL-1 (Odoo Proprietary License v1.0)

    Claims-specific extensions to the base technician task views
    defined in fusion_tasks. Adds SO/PO/rental fields.
-->
<odoo>

    <!-- ================================================================== -->
    <!-- SEARCH VIEW EXTENSION                                              -->
    <!-- ================================================================== -->
    <record id="view_technician_task_search_claims" model="ir.ui.view">
        <field name="name">fusion.technician.task.search.claims</field>
        <field name="model">fusion.technician.task</field>
        <field name="inherit_id" ref="fusion_tasks.view_technician_task_search"/>
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='filter_pod']" position="after">
                <filter string="Has Purchase Order" name="has_po"
                        domain="[('purchase_order_id', '!=', False)]"/>
            </xpath>
        </field>
    </record>

    <!-- ================================================================== -->
    <!-- FORM VIEW EXTENSION                                                -->
    <!-- ================================================================== -->
    <record id="view_technician_task_form_claims" model="ir.ui.view">
        <field name="name">fusion.technician.task.form.claims</field>
        <field name="model">fusion.technician.task</field>
        <field name="inherit_id" ref="fusion_tasks.view_technician_task_form"/>
        <field name="arch" type="xml">
            <!-- Stat buttons: View Case + Purchase Order -->
            <xpath expr="//div[@name='button_box']" position="inside">
                <button name="action_view_sale_order" type="object"
                        class="oe_stat_button" icon="fa-file-text-o"
                        invisible="not sale_order_id">
                    <div class="o_field_widget o_stat_info">
                        <span class="o_stat_text">View Case</span>
                    </div>
                </button>
                <button name="action_view_purchase_order" type="object"
                        class="oe_stat_button" icon="fa-shopping-cart"
                        invisible="not purchase_order_id">
                    <div class="o_field_widget o_stat_info">
                        <span class="o_stat_text">Purchase Order</span>
                    </div>
                </button>
            </xpath>

            <!-- Add sale_order_id, purchase_order_id after priority -->
            <xpath expr="//field[@name='priority']" position="after">
                <field name="sale_order_id"/>
                <field name="purchase_order_id"/>
            </xpath>

            <!-- Add Rental Inspection tab after Completion tab -->
            <xpath expr="//page[@name='completion']" position="after">
                <page string="Rental Inspection" name="rental_inspection"
                      invisible="task_type != 'pickup'">
                    <group>
                        <group string="Condition">
                            <field name="rental_inspection_condition"/>
                            <field name="rental_inspection_completed"/>
                        </group>
                    </group>
                    <group string="Inspection Notes">
                        <field name="rental_inspection_notes" nolabel="1"/>
                    </group>
                    <group string="Inspection Photos">
                        <field name="rental_inspection_photo_ids"
                               widget="many2many_binary" nolabel="1"/>
                    </group>
                </page>
            </xpath>
        </field>
    </record>

    <!-- ================================================================== -->
    <!-- LIST VIEW EXTENSION                                                -->
    <!-- ================================================================== -->
    <record id="view_technician_task_list_claims" model="ir.ui.view">
        <field name="name">fusion.technician.task.list.claims</field>
        <field name="model">fusion.technician.task</field>
        <field name="inherit_id" ref="fusion_tasks.view_technician_task_list"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='pod_required']" position="after">
                <field name="sale_order_id" optional="hide"/>
                <field name="purchase_order_id" optional="hide"/>
            </xpath>
        </field>
    </record>

    <!-- Field Service menus moved to fusion_tasks standalone app -->

</odoo>
