<?xml version="1.0"?>
<odoo>

    <record id="account_payment_form" model="ir.ui.view">
            <field name="model">account.payment</field>
            <field name="inherit_id" ref="account.view_account_payment_form" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='communication']" position="after">
                    <field name="folio_id"/>
                </xpath>
            </field>
    </record>

    <record id="view_account_payment_folio_form" model="ir.ui.view">
        <field name="name">account.payment.folio.form</field>
        <field name="model">account.payment</field>
        <field name="arch" type="xml">
            <form string="Register Payment" version="7">
                <sheet>
                    <div class="oe_button_box" name="button_box">
                        <button class="oe_stat_button" name="button_journal_entries" string="Journal Items" type="object" groups="account.group_account_manager" attrs="{'invisible':[('move_line_ids','=',[])]}" icon="fa-bars"/>
                        <field name="move_line_ids" invisible="1"/>
                        <button class="oe_stat_button" name="button_invoices" string="Invoices" type="object" attrs="{'invisible':[('has_invoices','=',False)]}" icon="fa-bars"/>
                        <field name="has_invoices" invisible="1"/>
                    </div>
                    <group>
                        <field name="payment_type" invisible="1"/>
                        <field name="partner_type" invisible="1"/>
                        <field name="state" invisible="1"/>
                        <group>
                            <field name="journal_id" widget="selection"/>
                            <field name="partner_id"/>
                            <field name="hide_payment_method" invisible="1"/>
                            <field name="payment_method_id" widget="radio" attrs="{'invisible': [('hide_payment_method', '=', True)]}"/>
                            <field name="payment_method_code" invisible="1"/>
                            <label for="amount"/>
                            <div name="amount_div" class="o_row">
                                <field name="amount"/>
                            </div>
                        </group>
                        <group>
                            <field name="payment_date"/>
                            <field name="communication"/>
                            <field name="folio_id"/>
                        </group>
                        <group attrs="{'invisible': [('payment_difference', '=', 0.0)]}">
                            <label for="payment_difference"/>
                            <div>
                                <field name="payment_difference"/>
                                <field name="payment_difference_handling" widget="radio" nolabel="1"/>
                            </div>
                            <field name="writeoff_account_id" string="Post Difference In"
                                attrs="{'invisible': [('payment_difference_handling','=','open')], 'required': [('payment_difference_handling', '=', 'reconcile')]}"/>
                        </group>
                    </group>
                </sheet>
                <footer>
                    <button string="Validate" name="post" type="object" class="btn-primary"
                    attrs="{'invisible': [('state','!=','draft')]}"/>
                    <button string="Modify" name="modify" type="object" class="btn-primary"
                    attrs="{'invisible': [('state','=','draft')]}"/>
                    <button string="Return" name="return_payment_folio" type="object" class="btn-primary"
                    attrs="{'invisible': [('state','=','draft')]}"/>
                    <button string="Delete" name="delete" type="object" class="btn-primary"
                    attrs="{'invisible': [('state','=','draft')]}"/>
                    <button string="Cancel" class="btn-default" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

</odoo>
