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

    <record id="view_order_form_poynt_button" model="ir.ui.view">
        <field name="name">sale.order.form.poynt.button</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="priority">60</field>
        <field name="arch" type="xml">
            <!-- Transaction count smart button -->
            <xpath expr="//div[@name='button_box']" position="inside">
                <button name="action_view_poynt_transactions"
                        type="object"
                        class="oe_stat_button"
                        icon="fa-credit-card"
                        invisible="poynt_transaction_count == 0">
                    <field name="poynt_transaction_count" widget="statinfo" string="Poynt Payments"/>
                </button>
            </xpath>

            <!-- Collect Payment action button -->
            <xpath expr="//button[@id='create_invoice']" position="after">
                <button name="action_poynt_collect_payment"
                        string="Collect Payment"
                        type="object"
                        class="btn-secondary"
                        icon="fa-credit-card"
                        invisible="state not in ('sale', 'done')"
                        groups="fusion_poynt.group_fusion_poynt_user"
                        data-hotkey="p"/>
            </xpath>
        </field>
    </record>

</odoo>
