<odoo>
    <record id="purchase_order_form_inherit_downpayment" model="ir.ui.view">
        <field name="name">purchase.order.form</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.purchase_order_form" />
        <field name="arch" type="xml">
            <button name="button_unlock" position="after">
                <button
                    name="%(action_view_po_downpayment_wizard)d"
                    string="Create Payment"
                    type="action"
                    groups="account.group_account_invoice"
                    attrs="{'invisible': [('state', 'not in', ['done','purchase'])]}"
                    class="oe_highlight"
                />
            </button>
            <xpath expr="//div[hasclass('oe_button_box')]" position="inside">
                <button
                    type="object"
                    name="action_open_payment"
                    class="oe_stat_button"
                    icon="fa-book"
                    attrs="{'invisible': [('payment_count', '=', 0)]}"
                    groups="account.group_account_invoice"
                >
                    <field name="payment_count" widget="statinfo" string="Payment" />
                </button>
            </xpath>
        </field>
    </record>
</odoo>
