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

    <!-- Extend the Fax Form: add smart buttons, forward, and send new -->
    <record id="view_fusion_fax_form_inherit_rc" model="ir.ui.view">
        <field name="name">fusion.fax.form.inherit.rc</field>
        <field name="model">fusion.fax</field>
        <field name="inherit_id" ref="fusion_faxes.view_fusion_fax_form"/>
        <field name="arch" type="xml">

            <!-- Add Forward and Send New buttons to header (RC users only) -->
            <xpath expr="//button[@name='action_resend']" position="after">
                <button name="action_forward_fax" string="Forward Fax"
                        type="object" class="btn-secondary"
                        icon="fa-share"
                        invisible="direction != 'inbound' or state != 'received'"
                        groups="fusion_ringcentral.group_rc_user"/>
                <button name="action_send_new_fax" string="Send New Fax"
                        type="object" class="btn-secondary"
                        icon="fa-fax"
                        groups="fusion_ringcentral.group_rc_user"/>
            </xpath>

            <!-- Add Contact, Sales Orders, Invoices smart buttons (RC users only) -->
            <xpath expr="//div[@name='button_box']" position="inside">
                <button name="action_view_contact" type="object"
                        class="oe_stat_button" icon="fa-user"
                        invisible="not partner_id"
                        groups="fusion_ringcentral.group_rc_user">
                    <div class="o_stat_info">
                        <span class="o_stat_text"><field name="partner_id" readonly="1" nolabel="1" class="o_text_overflow"/></span>
                    </div>
                </button>
                <button name="action_view_sale_orders" type="object"
                        class="oe_stat_button" icon="fa-shopping-cart"
                        invisible="not partner_id"
                        groups="fusion_ringcentral.group_rc_user">
                    <field name="sale_order_count" widget="statinfo" string="Sales Orders"/>
                </button>
                <button name="action_view_invoices" type="object"
                        class="oe_stat_button" icon="fa-file-text-o"
                        invisible="not partner_id"
                        groups="fusion_ringcentral.group_rc_user">
                    <field name="invoice_count" widget="statinfo" string="Invoices"/>
                </button>
            </xpath>

        </field>
    </record>

</odoo>
