<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_sale_advance_payment_inv" model="ir.ui.view">
            <field name="name">Invoice Order</field>
            <field name="model">sale.advance.payment.inv</field>
            <field name="arch" type="xml">
                <form string="Invoice Sales Order">
                    <p class="oe_grey">
                        Select how you want to invoice this order. This
                        will create a draft invoice that can be modified
                        before validation.
                    </p>
                    <group>
                        <field name="advance_payment_method" class="oe_inline"
                            on_change="onchange_method(advance_payment_method, product_id)"/>
                        <field name="qtty" invisible="1"/>
                        <field name="product_id"
                            on_change="onchange_method(advance_payment_method, product_id)"
                            context="{'search_default_services': 1}"
                            attrs="{'invisible': [('advance_payment_method','!=','fixed')]}"/>
                        <label for="amount" attrs="{'invisible': [('advance_payment_method', 'not in', ('fixed','percentage'))]}"/>
                        <div attrs="{'invisible': [('advance_payment_method', 'not in', ('fixed','percentage'))]}">
                            <field name="amount"
                                attrs="{'required': [('advance_payment_method', 'in', ('fixed','percentage'))]}" class="oe_inline"/>
                            <label string="%%"
                                attrs="{'invisible': [('advance_payment_method', '!=', 'percentage')]}" class="oe_inline"/>
                        </div>
                    </group>
                    <div>
                        <b><label string="After clicking 'Show Lines to Invoice', select lines to invoice and create the invoice from the 'More' dropdown menu." attrs="{'invisible': [('advance_payment_method', '!=', 'lines')]}"/></b>
                    </div>
                    <footer>
                        <button name="create_invoices" string="Create and View Invoice" type="object"
                            context="{'open_invoices': True}" class="oe_highlight"
                            attrs="{'invisible': [('advance_payment_method', '=', 'lines')]}"/>
                        <button name="create_invoices" string="Create Invoice" type="object"
                            class="oe_highlight"
                            attrs="{'invisible': [('advance_payment_method', '=', 'lines')]}"/>
                        <button name="create_invoices" string="Show Lines to Invoice" type="object"
                            class="oe_highlight"
                            attrs="{'invisible': [('advance_payment_method', '!=', 'lines')]}"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

        <record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window">
            <field name="name">Invoice Order</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.advance.payment.inv</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>
    </data>
</openerp>
