<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="view_marketplace_order_form" model="ir.ui.view">
            <field name="name">marketplace.order.form</field>
            <field name="model">marketplace.order</field>
            <field name="arch" type="xml">
                <form>
                    <header/>
                    <sheet>
                        <group>
                            <group>
                                <field name="name"/>
                                <field name="uuid" readonly="1"/>
                                <field name="team_uuid"/>
                                <field name="user_id"/>
                            </group>
                            <group>
                                <field name="source_location_id"/>
                                <field name="destination_location_id"/>
                                <field name="total_amount"/>
                                <field name="currency_id"/>
                            </group>
                        </group>
                        <group>
                            <field name="created_at" readonly="1"/>
                            <field name="updated_at" readonly="1"/>
                        </group>
                        <notebook>
                            <page string="Stages">
                                <group string="Logistics Stages">
                                    <field name="stage_ids" mode="kanban" nolabel="1"
                                           context="{'default_order_id': id}">
                                        <kanban>
                                            <field name="name"/>
                                            <field name="stage_type"/>
                                            <field name="transport_type"/>
                                            <field name="source_location_id"/>
                                            <field name="destination_location_id"/>
                                            <field name="location_id"/>
                                            <templates>
                                                <t t-name="kanban-box">
                                                    <div class="oe_kanban_card oe_kanban_global_click">
                                                        <div class="o_kanban_record_top">
                                                            <div class="o_kanban_record_headings">
                                                                <strong class="o_kanban_record_title">
                                                                    <field name="name"/>
                                                                </strong>
                                                                <div class="o_kanban_record_subtitle">
                                                                    <t t-if="record.stage_type.raw_value == 'transport'">
                                                                        <i class="fa fa-truck" title="Transport"/>
                                                                        <field name="transport_type"/>
                                                                    </t>
                                                                    <t t-else="">
                                                                        <i class="fa fa-cogs" title="Service"/> Service
                                                                    </t>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="o_kanban_record_body">
                                                            <div t-if="record.stage_type.raw_value == 'transport'" class="mb-1">
                                                                <small><i class="fa fa-map-marker" title="Route"/>
                                                                <field name="source_location_id"/> → <field name="destination_location_id"/></small>
                                                            </div>
                                                            <div t-else="" class="mb-1">
                                                                <small><i class="fa fa-map-marker" title="Location"/>
                                                                <field name="location_id"/></small>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </t>
                                            </templates>
                                        </kanban>
                                    </field>
                                </group>
                            </page>
                            <page string="Order Lines">
                                <field name="order_lines">
                                    <list>
                                        <field name="product_id"/>
                                        <field name="quantity"/>
                                        <field name="unit"/>
                                        <field name="price_unit"/>
                                        <field name="subtotal"/>
                                        <field name="currency_id"/>
                                    </list>
                                </field>
                            </page>
                            <page string="Tracking">
                                <field name="tracking_events">
                                    <list>
                                        <field name="timestamp"/>
                                        <field name="stage_id"/>
                                        <field name="trip_id"/>
                                        <field name="location_id"/>
                                        <field name="description"/>
                                    </list>
                                </field>
                            </page>
                            <page string="Notes">
                                <field name="notes" placeholder="Additional notes..."/>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>
    </data>
</odoo>
