<?xml version="1.0" ?>
<openerp>
  <data>

    <!-- Batch Payment Info form -->
    
    <record id="view_statement_line_global_form" model="ir.ui.view">
      <field name="name">statement.line.global.form</field>
      <field name="model">account.bank.statement.line.global</field>
      <field name="arch" type="xml">
        <form string="Batch Payment Info" version="7.0">
            <group col="4">
                <field name="name"/>
                <field name="amount"/>
                <field name="code"/>
                <field name="parent_id"/>
                <field name="type"/>
            </group>
            <notebook>
                <page string="Transactions">
                  <field name="bank_statement_line_ids"/>
                </page>
                <page string="Child Batch Payments">
                  <field name="child_ids">
                    <tree string="Child Batch Payments">
                      <field name="name"/>
                      <field name="amount"/>
                      <field name="code"/>
                    </tree>
                  </field>
                </page>
            </notebook>
        </form>
      </field>
    </record>
    
    <!-- add Valuta Date and Globalisation id to bank statement line -->
    
    <record id="view_bank_statement_form_add_fields" model="ir.ui.view">
      <field name="name">view.bank.statement.form.add.fields</field>
      <field name="model">account.bank.statement</field>
      <field name="inherit_id" ref="account.view_bank_statement_form"/>
      <field name="arch" type="xml">
        <data>
          <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='date']" position="after">
            <field name="val_date" invisible="1"/>
          </xpath> 
          <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
            <field name="globalisation_id" string="Glob. Id" invisible="1"/>
            <field name="state" invisible="1"/>
          </xpath>
          <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/form/group/field[@name='date']" position="after">
            <field name="val_date"/>
          </xpath>
          <xpath expr="//page[@name='statement_line_ids']/field[@name='line_ids']/form/group/field[@name='amount']" position="after">
            <field name="globalisation_id"/>
            <field name="state" invisible="1"/>
          </xpath>
        </data>
      </field>
    </record>

    <!-- Bank Statement Line View -->

    <record id="view_bank_statement_line_list" model="ir.ui.view">
      <field name="name">bank.statement.line.list</field>
      <field name="model">account.bank.statement.line</field>
      <field name="arch" type="xml">
        <tree editable="bottom" string="Statement Lines">
          <field name="sequence" readonly="1" invisible="1"/>
          <field name="journal_id" readonly="1"/>
          <field name="date" readonly="1"/>
          <field name="val_date" readonly="1"/>
          <field name="name"/>
          <field name="statement_id"/>
          <field name="ref" readonly="1"/>
          <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
          <field name="type" on_change="onchange_type(partner_id, type)"/>
          <field name="account_id"/>
          <field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type', '&lt;&gt;', 'view')]"/>
          <field name="amount" readonly="1" sum="Total Amount"/>
          <field name="globalisation_id" string="Glob. Id"/>
          <field name="globalisation_amount" string="Glob. Am."/>
          <field name="state"/>
        </tree>
      </field>
    </record>

    <record id="view_bank_statement_line_form" model="ir.ui.view">
      <field name="name">bank.statement.line.form</field>
      <field name="model">account.bank.statement.line</field>
      <field name="arch" type="xml">
        <form string="Statement Line" version="7.0">
          <group col="4">
              <field name="statement_id"/>
              <field name="journal_id"/>
              <field name="date"/>
              <field name="val_date"/>
              <field name="name"/>
              <field name="ref" readonly="0"/>
              <field name="partner_id" on_change="onchange_partner_id(partner_id)"/>
              <field name="type" on_change="onchange_type(partner_id, type)"/>
              <field domain="[('type', '&lt;&gt;', 'view')]" name="account_id"/>
              <field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('type', '&lt;&gt;', 'view')]"/>
              <field name="amount"/>
              <field name="globalisation_id"/>
              <field name="sequence" readonly="0"/>
              <field name="state"/>
          </group>
          <separator string="Notes"/>
          <field name="note"/>
        </form>
      </field>
    </record>

    <record id="view_bank_statement_line_filter" model="ir.ui.view">
        <field name="name">bank.statement.line.filter</field>
        <field name="model">account.bank.statement.line</field>
        <field name="arch" type="xml">
            <search string="Search Bank Transactions">
                <field name="name" filter_domain="['|', ('name','ilike',self), ('ref','ilike',self)]" string="Bank Transaction"/>
                <field name="val_date"/>
                <filter name="debit" string="Debit" domain="[('amount','&gt;',0)]" icon="terp-folder-green" help="Debit Transactions."/>
                <filter name="credit" string="Credit" domain="[('amount','&lt;',0)]" icon="terp-folder-orange" help="Credit Transactions."/>
                <separator/>
                <filter name="draft" string="Draft" domain="[('state','=','draft')]" icon="terp-document-new" help="Draft Statement Lines."/>
                <filter name="confirm" string="Confirmed" domain="[('state','=','confirm')]" icon="terp-camera_test" help="Confirmed Statement Lines."/>
                <field name="journal_id"/>
                <field name="statement_id"/>
                <field name="globalisation_id" string="Glob. Id"/>
                <group string="Extended Filters..." expand="0">
                    <field name="account_id"/>
                    <field name="partner_id"/>
                    <field name="amount"/>
                    <field name="globalisation_amount" string="Glob. Amount"/>
                    <field name="note"/>
                </group>
                <group string="Group By..." expand="1">
                    <filter string="Journal" context="{'group_by':'journal_id'}" icon="terp-folder-green"/>
                    <filter string="Statement" context="{'group_by':'statement_id'}" icon="terp-folder-orange"/>
                    <filter string="Fin.Account" context="{'group_by':'account_id'}" icon="terp-folder-yellow"/>
                </group>
            </search>
        </field>
    </record>

    <record id="action_bank_statement_line" model="ir.actions.act_window">
      <field name="name">Bank Statement Lines</field>
      <field name="res_model">account.bank.statement.line</field>
      <field name="view_type">form</field>
      <field name="view_mode">tree,form</field>
      <field name="context">{'block_statement_line_delete' : 1}</field>
      <field name="search_view_id" ref="view_bank_statement_line_filter"/>
      <field name="view_id" ref="view_bank_statement_line_list"/>
    </record>

    <menuitem action="action_bank_statement_line" id="bank_statement_line" parent="account.menu_finance_bank_and_cash" sequence="20" groups="base.group_no_one"/>

  </data>
</openerp>
