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

    <record id="view_account_payment_search" model="ir.ui.view">
        <field name="name">account.payment.search</field>
        <field name="model">account.payment</field>
        <field name="inherit_id" ref="account.view_account_payment_search" />
        <field name="arch" type="xml">
            <filter name="transfers_filter" position="after">
                <separator />
                <filter
                    string="Vendor Advance Payments"
                    name="vendor_adv_payment_filter"
                    domain="[('purchase_id', '!=', False)]"
                />
                <separator />
            </filter>
            <filter name="state_sent" position="after">
                <filter
                    string="Not Sent"
                    name="state_not_sent"
                    domain="[('is_move_sent', '=', False)]"
                />
            </filter>
            <filter name="reconciled" position="after">
                <filter
                    string="Not Reconciled"
                    name="reconciled"
                    domain="[('is_reconciled', '=', False)]"
                />
            </filter>
        </field>
    </record>

    <record id="view_account_supplier_payment_tree" model="ir.ui.view">
        <field name="name">account.payment.search</field>
        <field name="model">account.payment</field>
        <field name="inherit_id" ref="account.view_account_supplier_payment_tree" />
        <field name="arch" type="xml">
            <field name="partner_id" position="after">
                <field
                    name="is_move_sent"
                    string="Payment Sent?"
                    invisible="not context.get('search_default_vendor_adv_payment_filter')"
                />
            </field>
        </field>
    </record>

     <record id="action_account_advance_payments_payable" model="ir.actions.act_window">
        <field name="name">Advance Payments</field>
        <field name="res_model">account.payment</field>
        <field name="view_mode">tree,kanban,form,graph</field>
        <field name="context">{
            'default_payment_type': 'outbound',
            'default_partner_type': 'supplier',
            'search_default_vendor_adv_payment_filter': 1,
            'default_move_journal_types': ('bank', 'cash'),
        }</field>
        <field name="view_id" ref="view_account_supplier_payment_tree" />
    </record>

    <menuitem
        id="menu_account_advance_payments_payable"
        action="action_account_advance_payments_payable"
        parent="account.menu_finance_payables"
        sequence="22"
    />

</odoo>
