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

    <!-- Tree View -->
    <record id="view_network_log_list" model="ir.ui.view">
        <field name="name">network.log.list</field>
        <field name="model">network.log</field>
        <field name="arch" type="xml">
            <list string="Network Logs" default_order="timestamp desc"
                  decoration-danger="is_odoo_call"
                  decoration-success="status_type == 'success'">
                <field name="timestamp"/>
                <field name="method"/>
                <field name="domain"/>
                <field name="url" optional="hide"/>
                <field name="is_odoo_call"/>
                <field name="status_code"/>
                <field name="status_type"/>
                <field name="response_time" optional="show"/>
            </list>
        </field>
    </record>

    <!-- Form View -->
    <record id="view_network_log_form" model="ir.ui.view">
        <field name="name">network.log.form</field>
        <field name="model">network.log</field>
        <field name="arch" type="xml">
            <form string="Network Log Entry" create="false" edit="false">
                <sheet>
                    <group>
                        <group string="Request Details">
                            <field name="timestamp"/>
                            <field name="method"/>
                            <field name="domain"/>
                            <field name="url"/>
                            <field name="is_odoo_call"/>
                        </group>
                        <group string="Response Details">
                            <field name="status_code"/>
                            <field name="status_type"/>
                            <field name="response_time"/>
                        </group>
                    </group>
                    <group string="Error Details" invisible="error_message == False">
                        <field name="error_message" readonly="1"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Search View - Minimal -->
    <record id="view_network_log_search" model="ir.ui.view">
        <field name="name">network.log.search</field>
        <field name="model">network.log</field>
        <field name="arch" type="xml">
            <search>
                <field name="url"/>
                <field name="domain"/>
            </search>
        </field>
    </record>

    <!-- Action -->
    <record id="action_network_log" model="ir.actions.act_window">
        <field name="name">Network Traffic Logs</field>
        <field name="res_model">network.log</field>
        <field name="view_mode">list,form</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                No network traffic logged yet
            </p>
        </field>
    </record>

    <!-- Action for Odoo Calls Only -->
    <record id="action_network_log_odoo_calls" model="ir.actions.act_window">
        <field name="name">Odoo External Calls</field>
        <field name="res_model">network.log</field>
        <field name="view_mode">list,form</field>
        <field name="domain">[('is_odoo_call', '=', True)]</field>
    </record>

    <!-- Menu Items -->
    <menuitem id="menu_network_logger_root"
              name="Network Logger"
              parent="base.menu_administration"
              sequence="100"/>

    <menuitem id="menu_network_log_all"
              name="All Traffic"
              parent="menu_network_logger_root"
              action="action_network_log"
              sequence="10"/>

    <menuitem id="menu_network_log_odoo"
              name="Odoo External Calls"
              parent="menu_network_logger_root"
              action="action_network_log_odoo_calls"
              sequence="20"/>

</odoo>
