<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- List View -->
    <record id="view_logistics_node_list" model="ir.ui.view">
        <field name="name">logistics.node.list</field>
        <field name="model">logistics.node</field>
        <field name="arch" type="xml">
            <list string="Logistics Nodes">
                <field name="uuid"/>
                <field name="name"/>
                <field name="latitude"/>
                <field name="longitude"/>
                <button name="action_add_to_graph" 
                        type="object" 
                        icon="fa-plus" 
                        string="Add to Graph"/>
            </list>
        </field>
    </record>

    <!-- Form View -->
    <record id="view_logistics_node_form" model="ir.ui.view">
        <field name="name">logistics.node.form</field>
        <field name="model">logistics.node</field>
        <field name="arch" type="xml">
            <form string="Logistics Node">
                <header>
                    <button name="action_add_to_graph" 
                            type="object" 
                            string="Add to Graph" 
                            class="btn-primary"
                            invisible="not has_auto_connection"/>
                </header>
                <sheet>
                    <group>
                        <group>
                            <field name="uuid" readonly="1"/>
                            <field name="name" placeholder="Например: Склад Москва-Север"/>
                            <field name="country_id"/>
                        </group>
                    </group>
                    <group>
                        <group string="Coordinates">
                            <field name="latitude" placeholder="55.7558"/>
                            <field name="longitude" placeholder="37.6176"/>
                        </group>
                        <group string="Isochrones">
                            <field name="isochrone_ids"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Connections" name="connections">
                            <field name="connection_ids">
                                <list editable="bottom">
                                    <field name="name"/>
                                    <field name="transport_category_id"/>
                                    <field name="loading_type_id"/>
                                    <field name="active"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Search View -->
    <record id="view_logistics_node_search" model="ir.ui.view">
        <field name="name">logistics.node.search</field>
        <field name="model">logistics.node</field>
        <field name="arch" type="xml">
            <search string="Search Logistics Nodes">
                <field name="name"/>
                <field name="latitude"/>
                <field name="longitude"/>
                <group expand="0" string="Group By">
                </group>
            </search>
        </field>
    </record>

    <!-- Action -->
    <record id="action_logistics_node" model="ir.actions.act_window">
        <field name="name">Logistics Nodes</field>
        <field name="res_model">logistics.node</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_logistics_node_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first logistics node
            </p>
            <p>
                Logistics nodes are used to build isochrones - accessibility zones
                within a 24-hour drive by car. When creating a node, a task to build
                an isochrone is automatically launched via Prefect + Valhalla.
            </p>
        </field>
    </record>
</odoo>