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

    <!-- Renewal Log List View -->
    <record id="rental_renewal_log_view_list" model="ir.ui.view">
        <field name="name">rental.renewal.log.list</field>
        <field name="model">rental.renewal.log</field>
        <field name="arch" type="xml">
            <list string="Renewal History" create="false">
                <field name="order_id"/>
                <field name="partner_id"/>
                <field name="renewal_number"/>
                <field name="renewal_type"/>
                <field name="previous_start_date"/>
                <field name="previous_return_date"/>
                <field name="new_start_date"/>
                <field name="new_return_date"/>
                <field name="invoice_id"/>
                <field name="payment_status"
                       decoration-success="payment_status == 'paid'"
                       decoration-danger="payment_status == 'failed'"
                       decoration-warning="payment_status == 'pending'"
                       widget="badge"/>
                <field name="state"
                       decoration-success="state == 'done'"
                       decoration-danger="state == 'failed'"
                       decoration-info="state == 'draft'"
                       widget="badge"/>
            </list>
        </field>
    </record>

    <!-- Renewal Log Form View -->
    <record id="rental_renewal_log_view_form" model="ir.ui.view">
        <field name="name">rental.renewal.log.form</field>
        <field name="model">rental.renewal.log</field>
        <field name="arch" type="xml">
            <form string="Renewal Log" create="false">
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="order_id" readonly="1"/>
                            <span> - Renewal #</span>
                            <field name="renewal_number" readonly="1" class="oe_inline"/>
                        </h1>
                    </div>
                    <group>
                        <group string="Renewal Details">
                            <field name="renewal_type"/>
                            <field name="state"/>
                            <field name="partner_id"/>
                        </group>
                        <group string="Payment">
                            <field name="invoice_id"/>
                            <field name="payment_status"/>
                            <field name="payment_transaction_id"/>
                        </group>
                    </group>
                    <group>
                        <group string="Previous Period">
                            <field name="previous_start_date"/>
                            <field name="previous_return_date"/>
                        </group>
                        <group string="New Period">
                            <field name="new_start_date"/>
                            <field name="new_return_date"/>
                        </group>
                    </group>
                    <group string="Notes">
                        <field name="notes" nolabel="1"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Renewal Log Action -->
    <record id="action_rental_renewal_log" model="ir.actions.act_window">
        <field name="name">Renewal History</field>
        <field name="res_model">rental.renewal.log</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'create': False}</field>
    </record>

</odoo>
