<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <!-- Vista tree de ventas -->
        <record id="view_skeen_venta_tree" model="ir.ui.view">
            <field name="name">skeen.venta.tree</field>
            <field name="model">skeen.venta</field>
            <field name="arch" type="xml">
                <tree decoration-success="state=='paid'" decoration-warning="state=='partial'" decoration-muted="state=='cancelled'">
                    <field name="name" />
                    <field name="partner_id" />
                    <field name="date" />
                    <field name="total" />
                    <field name="amount_paid" />
                    <field name="amount_due" />
                    <field name="state" />
                </tree>
            </field>
        </record>

        <!-- Vista form de ventas -->
        <record id="view_skeen_venta_form" model="ir.ui.view">
            <field name="name">skeen.venta.form</field>
            <field name="model">skeen.venta</field>
            <field name="arch" type="xml">
                <form>
                    <header>
                        <button name="action_confirm" string="Confirmar" type="object" invisible="state != 'draft'" class="oe_highlight" />
                        <button name="action_mark_paid" string="Marcar Pagada" type="object" invisible="state not in ('confirmed', 'partial')" class="oe_highlight" />
                        <button name="action_cancel" string="Cancelar" type="object" invisible="state not in ('draft', 'confirmed', 'partial')" />
                        <field name="state" widget="statusbar" />
                    </header>
                    <sheet>
                        <group>
                            <group>
                                <field name="name" />
                                <field name="partner_id" />
                                <field name="cita_id" />
                                <field name="date" />
                            </group>
                            <group>
                                <field name="subtotal" />
                                <field name="discount" />
                                <field name="points_discount" />
                                <field name="tax" />
                                <field name="total" />
                                <field name="amount_paid" />
                                <field name="amount_due" />
                            </group>
                        </group>
                        <field name="line_ids">
                            <tree editable="bottom">
                                <field name="service_id" />
                                <field name="description" />
                                <field name="quantity" />
                                <field name="price_unit" />
                                <field name="subtotal" />
                            </tree>
                        </field>
                        <field name="notes" />
                    </sheet>
                </form>
            </field>
        </record>

        <!-- Action -->
        <record id="action_skeen_venta" model="ir.actions.act_window">
            <field name="name">Ventas</field>
            <field name="res_model">skeen.venta</field>
            <field name="view_mode">tree,form</field>
        </record>
    </data>
</odoo>
