<openerp>
    <data>

        <record id="view_partner_property_form" model="ir.ui.view">
            <field name="name">res.partner.purchase.property.form.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="priority">36</field>
            <field name="arch" type="xml">
                <field name="property_product_pricelist" position="after">
                    <field name="property_product_pricelist_purchase" groups="product.group_purchase_pricelist"/>
                </field>
            </field>
        </record>
        
    <record id="act_res_partner_2_purchase_order" model="ir.actions.act_window">
            <field name="name">RFQs and Purchases</field>
            <field name="res_model">purchase.order</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,graph</field>
            <field name="context">{'search_default_partner_id': active_id}</field>
            <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">
                    This supplier has no purchase order. Click to create a new RfQ.
                </p><p>
                    The request for quotation is the first step of the purchases flow. Once
                    converted into a purchase order, you will be able to control the receipt
                    of the products and the supplier invoice.
                </p>
            </field>
        </record>

        <!-- Partner kanban view inherited -->
        <record model="ir.ui.view" id="purchase_partner_kanban_view">
            <field name="name">res.partner.kanban.purchaseorder.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.res_partner_kanban_view"/>
            <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
            <field name="arch" type="xml">
                <field name="mobile" position="after">
                    <field name="purchase_order_count"/>
                </field>
                
                <xpath expr="//div[@class='oe_kanban_partner_links']" position="inside">
                    <a name="%(purchase.act_res_partner_2_purchase_order)d" type="action" t-if="record.purchase_order_count.value>0">
                        <t t-esc="record.purchase_order_count.value"/> Purchases
                    </a>
                </xpath>
            </field>
        </record>
        
    <record id="act_res_partner_2_supplier_invoices" model="ir.actions.act_window">
            <field name="name">Supplier Invoices</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,graph</field>
            <field name="domain">[('type','=','in_invoice')]</field>
            <field name="context">{'search_default_partner_id': active_id, 'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'}</field>
            <field name="help" type="html">
                <p class="oe_view_nocontent_create">
                    Click here to record a supplier invoice.
                </p><p>
                    Supplier invoices can be pre-generated based on purchase
                    orders or receipts. This allows you to control invoices
                    you receive from your supplier according to the draft
                    document in Odoo.
                </p>
            </field>
        </record>

        <record id="res_partner_view_purchase_buttons" model="ir.ui.view">
            <field name="name">res.partner.view.purchase.buttons</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="priority" eval="20"/>
            <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/>
            <field name="arch" type="xml">
                <xpath expr="//div[@name='buttons']" position="inside">
                    <button class="oe_inline oe_stat_button" name="%(purchase.act_res_partner_2_purchase_order)d" type="action"
                        attrs="{'invisible': [('supplier', '=', False)]}" icon="fa-shopping-cart">
                        <field string="Purchases" name="purchase_order_count" widget="statinfo"/>
                    </button>
                </xpath>
            </field>
        </record>
        
        <record id="res_partner_view_purchase_account_buttons" model="ir.ui.view">
            <field name="name">res.partner.view.purchase.account.buttons</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="priority" eval="20"/>
            <field name="groups_id" eval="[(4, ref('account.group_account_user'))]"/>
            <field name="arch" type="xml">
                <xpath expr="//div[@name='buttons']" position="inside">
                    <button class="oe_inline oe_stat_button" name="%(purchase.act_res_partner_2_supplier_invoices)d" type="action"
                        attrs="{'invisible': [('supplier', '=', False)]}" icon="fa-pencil-square-o" help="Supplier Invoices">
                        <field string="Supplier Inv." name="supplier_invoice_count" widget="statinfo"/>
                    </button>
                </xpath>
            </field>
        </record>
    </data>
</openerp>
