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

    <!-- Tree View -->
    <record id="view_api_user_limit_tree" model="ir.ui.view">
        <field name="name">fusion.api.user.limit.tree</field>
        <field name="model">fusion.api.user.limit</field>
        <field name="arch" type="xml">
            <list editable="bottom">
                <field name="user_id"/>
                <field name="provider_id"/>
                <field name="monthly_budget_usd"/>
                <field name="max_rpd"/>
                <field name="is_blocked" widget="boolean_toggle"/>
                <field name="current_month_cost" string="Month Spend ($)"/>
                <field name="current_day_requests" string="Today Reqs"/>
            </list>
        </field>
    </record>

    <!-- Form View -->
    <record id="view_api_user_limit_form" model="ir.ui.view">
        <field name="name">fusion.api.user.limit.form</field>
        <field name="model">fusion.api.user.limit</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group>
                        <group>
                            <field name="user_id"/>
                            <field name="provider_id"/>
                            <field name="is_blocked"/>
                        </group>
                        <group>
                            <field name="monthly_budget_usd"/>
                            <field name="max_rpd"/>
                        </group>
                    </group>
                    <group>
                        <group string="Current Usage">
                            <field name="current_month_cost"/>
                            <field name="current_day_requests"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Action -->
    <record id="action_api_user_limit" model="ir.actions.act_window">
        <field name="name">User Limits</field>
        <field name="res_model">fusion.api.user.limit</field>
        <field name="view_mode">list,form</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                No user limits configured
            </p>
            <p>Set per-user budget caps and request limits, or block individual users from API access.</p>
        </field>
    </record>

</odoo>
