<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 2024-2026 Nexa Systems Inc.
    License OPL-1 (Odoo Proprietary License v1.0)
    Part of the Fusion Claim Assistant product family.

    ADP Product toggle and linked device code fields on the product form.
-->
<odoo>

    <!-- ADP Product checkbox in the top options row -->
    <record id="view_product_template_adp_toggle" model="ir.ui.view">
        <field name="name">product.template.form.fusion.claims.adp.toggle</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_form_view"/>
        <field name="priority">165</field>
        <field name="arch" type="xml">
            <xpath expr="//div[@name='options']" position="inside">
                <span class="d-inline-flex">
                    <field name="x_fc_is_adp_product"/>
                    <label for="x_fc_is_adp_product" string="ADP Product"/>
                </span>
            </xpath>
        </field>
    </record>

    <!-- ADP Information section (visible only when ADP Product is toggled) -->
    <record id="view_product_template_adp_section" model="ir.ui.view">
        <field name="name">product.template.form.fusion.claims.adp.section</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_only_form_view"/>
        <field name="priority">170</field>
        <field name="arch" type="xml">
            <xpath expr="//group[@name='group_standard_price']" position="inside">
                <separator string="ADP Information"
                           invisible="not x_fc_is_adp_product"/>
                <field name="x_fc_adp_device_code_id"
                       invisible="not x_fc_is_adp_product"
                       required="x_fc_is_adp_product"/>
                <field name="x_fc_adp_device_code"
                       invisible="not x_fc_is_adp_product"
                       readonly="1"/>
                <field name="x_fc_adp_price"
                       invisible="not x_fc_is_adp_product"
                       readonly="1"/>
                <field name="x_fc_adp_device_type"
                       invisible="not x_fc_is_adp_product"
                       readonly="1"/>
                <field name="x_fc_adp_build_type"
                       invisible="not x_fc_is_adp_product"
                       readonly="1"/>
                <field name="x_fc_adp_max_quantity"
                       invisible="not x_fc_is_adp_product"
                       readonly="1"/>
            </xpath>
        </field>
    </record>

    <!-- ADP filters and grouping in product search view -->
    <record id="view_product_template_search_adp" model="ir.ui.view">
        <field name="name">product.template.search.fusion.claims.adp</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_search_view"/>
        <field name="priority">170</field>
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='filter_to_sell']" position="after">
                <filter string="ADP Product" name="filter_adp_product"
                        domain="[('x_fc_is_adp_product', '=', True)]"/>
            </xpath>
            <xpath expr="//filter[@name='group_by_categ_id']" position="after">
                <filter string="ADP Device Type" name="group_by_adp_device_type"
                        context="{'group_by': 'x_fc_adp_device_type'}"/>
            </xpath>
        </field>
    </record>

</odoo>
