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

    <!-- Extend vendor bills list view to show rappel_pending column -->
    <record id="view_in_invoice_bill_tree_rappel" model="ir.ui.view">
        <field name="name">account.move.tree.rappel</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_invoice_tree"/>
        <field name="arch" type="xml">
            <field name="checked" position="after">
                <field name="rappel_pending"
                       optional="show"
                       readonly="1"
                       widget="boolean_toggle"
                       column_invisible="context.get('default_move_type') not in ('in_invoice', 'in_refund')"/>
            </field>
        </field>
    </record>

    <!-- Extend the invoice search view to add the "Pending Commission" filter -->
    <record id="view_account_invoice_filter_rappel" model="ir.ui.view">
        <field name="name">account.invoice.select.rappel</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_account_invoice_filter"/>
        <field name="arch" type="xml">
            <filter name="to_check" position="after">
                <separator/>
                <filter name="rappel_pending"
                        string="Pending Commission"
                        domain="[('rappel_pending', '=', True)]"
                        help="Vendor bills not yet included in a rappel commission invoice"/>
            </filter>
        </field>
    </record>

    <!-- Extend vendor bill form view to show rappel_pending field -->
    <record id="view_move_form_rappel" model="ir.ui.view">
        <field name="name">account.move.form.rappel</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <xpath expr="//group[@name='accounting_info_group']/field[@name='checked']" position="after">
                <field name="rappel_pending"
                       invisible="move_type not in ('in_invoice', 'in_refund')"
                       readonly="1"
                       widget="boolean_toggle"/>
            </xpath>
        </field>
    </record>

</odoo>
