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

    <record id="view_account_payment_register_form" model="ir.ui.view">
        <field name="name">account.payment.register.form</field>
        <field name="model">account.payment.register</field>
        <field name="inherit_id" ref="account.view_account_payment_register_form"/>
        <field name="arch" type="xml">
            <field name="payment_method_line_id" position="after">
                <field name="l10n_latam_manual_checks" invisible="1"/>
                <field name="payment_method_code" invisible="1"/>
                <field name="l10n_latam_check_number"
                    invisible="payment_method_code != 'new_third_party_checks' and (not l10n_latam_manual_checks or payment_method_code != 'check_printing')"
                    required="(payment_method_code == 'check_printing' and l10n_latam_manual_checks) or payment_method_code == 'new_third_party_checks'"/>

                <div class="o_row"
                        invisible="not can_edit_wizard or can_group_payments and not group_payment" colspan="2">
                    <group>
                        <field name="l10n_latam_check_id"
                            invisible="payment_method_code not in ['in_third_party_checks', 'out_third_party_checks']"
                            required="payment_method_code in ['in_third_party_checks', 'out_third_party_checks']"
                            domain="
                                [('payment_method_code', '=', 'new_third_party_checks'), ('l10n_latam_check_current_journal_id', '=', journal_id), ('state', '=', 'posted')]
                                    if payment_type == 'outbound' else
                                [('payment_method_code', '=', 'new_third_party_checks'), ('l10n_latam_check_current_journal_id', '=', False), ('state', '=', 'posted')]"
                            options="{'no_create': True}"/>
                        <field name="l10n_latam_check_payment_date"
                            invisible="payment_method_code != 'new_third_party_checks' and (not l10n_latam_manual_checks or payment_method_code != 'check_printing')"/>
                        <field name="l10n_latam_check_bank_id" string="Check Bank"
                            invisible="payment_method_code != 'new_third_party_checks'"/>
                        <field name="l10n_latam_check_issuer_vat" string="Check Issuer Vat"
                            invisible="payment_method_code != 'new_third_party_checks'"/>
                    </group>
                </div>
                <div colspan="2" class="o_row"
                        invisible="payment_method_code not in ['new_third_party_checks', 'in_third_party_checks', 'out_third_party_checks'] or can_edit_wizard and (not can_group_payments or can_group_payments and group_payment)">
                    <p class="alert alert-warning" role="alert">You can't use checks when paying invoices of different partners or same partner without grouping</p>
                </div>
            </field>
        </field>
    </record>

</odoo>
