<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <!--
      © 2015-2016 Akretion (https://www.akretion.com/)
      @author: Alexis de Lattre <alexis.delattre@akretion.com>
      License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
    -->
    <record id="bank_payment_line_form" model="ir.ui.view">
        <field name="name">bank.payment.line.form</field>
        <field name="model">bank.payment.line</field>
        <field name="arch" type="xml">
            <form string="Bank Payment Line" create="false">
                <group name="main">
                    <field
                        name="order_id"
                        invisible="not context.get('bank_payment_line_main_view')"
                    />
                    <field name="name" />
                    <field
                        name="company_id"
                        groups="base.group_multi_company"
                        invisible="not context.get('bank_payment_line_main_view')"
                    />
                    <field name="partner_id" />
                    <field name="date" />
                    <field name="amount_currency" />
                    <field name="currency_id" invisible="1" />
                    <field name="partner_bank_id" />
                    <field name="communication_type" />
                    <field name="communication" />
                </group>
                <group string="Related Payment Lines" name="payment-lines">
                    <field name="payment_line_ids" nolabel="1" />
                </group>
            </form>
        </field>
    </record>
    <record id="bank_payment_line_tree" model="ir.ui.view">
        <field name="name">bank.payment.line.tree</field>
        <field name="model">bank.payment.line</field>
        <field name="arch" type="xml">
            <tree string="Bank Payment Lines" create="false">
                <field
                    name="order_id"
                    invisible="not context.get('bank_payment_line_main_view')"
                />
                <field name="partner_id" />
                <field name="communication" />
                <field name="partner_bank_id" />
                <field name="date" />
                <field name="amount_currency" sum="Total Amount" />
                <field name="currency_id" invisible="1" />
                <field name="name" optional="show" />
                <field
                    name="company_id"
                    groups="base.group_multi_company"
                    invisible="not context.get('bank_payment_line_main_view')"
                />
            </tree>
        </field>
    </record>
    <record id="bank_payment_line_search" model="ir.ui.view">
        <field name="name">bank.payment.line.search</field>
        <field name="model">bank.payment.line</field>
        <field name="arch" type="xml">
            <search string="Search Bank Payment Lines">
                <field name="partner_id" />
                <filter
                    name="inbound"
                    string="Inbound"
                    domain="[('payment_type', '=', 'inbound')]"
                />
                <filter
                    name="outbound"
                    string="Outbound"
                    domain="[('payment_type', '=', 'outbound')]"
                />
                <group string="Group By" name="groupby">
                    <filter
                        name="state_groupby"
                        string="State"
                        context="{'group_by': 'state'}"
                    />
                    <filter
                        name="partner_groupby"
                        string="Partner"
                        context="{'group_by': 'partner_id'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <record id="bank_payment_line_action" model="ir.actions.act_window">
        <field name="name">Bank Payment Lines</field>
        <field name="res_model">bank.payment.line</field>
        <field name="view_mode">tree,form</field>
        <field name="context">{'bank_payment_line_main_view': True}</field>
    </record>
    <menuitem
        id="bank_payment_line_menu"
        action="bank_payment_line_action"
        parent="account.menu_finance_payables"
        sequence="50"
        groups="group_account_payment"
    />
</odoo>
