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

    <!-- ============================================================ -->
    <!-- UPCHARGE RULE TREE VIEW                                       -->
    <!-- ============================================================ -->
    <record id="view_wc_upcharge_rule_tree" model="ir.ui.view">
        <field name="name">fusion.wc.upcharge.rule.tree</field>
        <field name="model">fusion.wc.upcharge.rule</field>
        <field name="arch" type="xml">
            <list>
                <field name="sequence" widget="handle"/>
                <field name="name"/>
                <field name="trigger_type"/>
                <field name="adp_device_code"/>
                <field name="equipment_type"/>
                <field name="mutually_exclusive_group"/>
                <field name="active"/>
            </list>
        </field>
    </record>

    <!-- ============================================================ -->
    <!-- UPCHARGE RULE FORM VIEW                                       -->
    <!-- ============================================================ -->
    <record id="view_wc_upcharge_rule_form" model="ir.ui.view">
        <field name="name">fusion.wc.upcharge.rule.form</field>
        <field name="model">fusion.wc.upcharge.rule</field>
        <field name="arch" type="xml">
            <form string="Upcharge Rule">
                <sheet>
                    <widget name="web_ribbon" title="Archived" bg_color="text-bg-danger"
                        invisible="active"/>
                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Rule Name"/>
                        </h1>
                    </div>
                    <group>
                        <group string="Trigger">
                            <field name="trigger_type"/>
                            <field name="equipment_type"/>
                            <field name="sequence"/>
                            <field name="active"/>
                        </group>
                        <group string="Result">
                            <field name="adp_device_code"/>
                            <field name="adp_device_code_id" readonly="1"/>
                            <field name="product_id"/>
                            <field name="mutually_exclusive_group"/>
                        </group>
                    </group>

                    <!-- Measurement trigger fields -->
                    <group string="Measurement Condition"
                        invisible="trigger_type != 'measurement'">
                        <group>
                            <field name="measurement_field"/>
                            <field name="comparison"/>
                            <field name="threshold_value"/>
                        </group>
                    </group>

                    <!-- Weight trigger fields -->
                    <group string="Weight Condition"
                        invisible="trigger_type != 'weight'">
                        <group>
                            <field name="weight_min"/>
                            <field name="weight_max"/>
                        </group>
                    </group>

                    <!-- Dimension mismatch fields -->
                    <group string="Dimension Mismatch Condition"
                        invisible="trigger_type != 'dimension_mismatch'">
                        <group>
                            <field name="compare_field_1"/>
                            <field name="compare_field_2"/>
                        </group>
                    </group>

                    <group>
                        <field name="description" placeholder="Explanation shown to sales rep when rule triggers..."/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- ============================================================ -->
    <!-- UPCHARGE RULE ACTION                                          -->
    <!-- ============================================================ -->
    <record id="action_wc_upcharge_rule" model="ir.actions.act_window">
        <field name="name">Upcharge Rules</field>
        <field name="res_model">fusion.wc.upcharge.rule</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'search_default_active': 1}</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Configure upcharge rules
            </p>
            <p>
                Define rules that auto-add ADP upcharge codes based on
                wheelchair measurements (e.g. WAMA for width > 18").
            </p>
        </field>
    </record>

</odoo>
