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

        <!-- Invoices -->
        <record id="view_invoice_line_calendar" model="ir.ui.view">
            <field name="name">account.invoice.calendar</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <calendar string="Invoices" color="journal_id" date_start="date_invoice">
                    <field name="partner_id"/>
                    <field name="amount_total"/>
                </calendar>
            </field>
        </record>

        <record model="ir.ui.view" id="view_invoice_graph">
            <field name="name">account.invoice.graph</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <graph string="Invoices" type="bar">
                    <field name="partner_id"/>
                    <field name="amount_total" operator="+"/>
                </graph>
            </field>
        </record>

        <record id="view_invoice_line_tree" model="ir.ui.view">
            <field name="name">account.invoice.line.tree</field>
            <field name="model">account.invoice.line</field>
            <field name="arch" type="xml">
                <tree string="Invoice Line">
                    <field name="name"/>
                    <field name="account_id" groups="account.group_account_user"/>
                    <field name="quantity"/>
                    <field name="uos_id" groups="product.group_uom"/>
                    <field name="price_unit"/>
                    <field name="discount" groups="sale.group_discount_per_so_line"/>
                    <field name="price_subtotal"/>
                </tree>
            </field>
        </record>

        <record id="view_invoice_line_form" model="ir.ui.view">
            <field name="name">account.invoice.line.form</field>
            <field name="model">account.invoice.line</field>
            <field name="arch" type="xml">
                <form string="Invoice Line">
                    <group>
                        <group>
                            <field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                            <label for="quantity"/>
                            <div>
                                <field name="quantity" class="oe_inline"/>
                                <field name="uos_id" class="oe_inline" groups="product.group_uom"
                                  on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                            </div>
                            <field name="price_unit"/>
                            <field name="discount" groups="sale.group_discount_per_so_line"/>
                        </group>
                        <group>
                            <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)" groups="account.group_account_user"/>
                            <field name="invoice_line_tax_id" context="{'type':parent.get('type')}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]" widget="many2many_tags"/>
                            <field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id)], ('state','not in',('close','cancelled'))]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
                            <field name="company_id" groups="base.group_multi_company" readonly="1"/>
                        </group>
                    </group>
                    <label for="name"/>
                    <field name="name"/>
                </form>
            </field>
        </record>

        <record id="view_invoice_tax_tree" model="ir.ui.view">
            <field name="name">account.invoice.tax.tree</field>
            <field name="model">account.invoice.tax</field>
            <field name="arch" type="xml">
                <tree string="Manual Invoice Taxes">
                    <field name="sequence"/>
                    <field name="manual"/>
                    <field name="name"/>
                    <field name="account_id" groups="base.group_account_user"/>
                    <field name="base"/>
                    <field name="amount"/>
                </tree>
            </field>
        </record>

        <record id="view_invoice_tax_form" model="ir.ui.view">
            <field name="name">account.invoice.tax.form</field>
            <field name="model">account.invoice.tax</field>
            <field name="arch" type="xml">
                <form string="Manual Invoice Taxes">
                    <group col="4">
                        <field name="name"/>
                        <field name="sequence"/>
                        <field name="account_id" groups="account.group_account_user"/>
                        <field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled')]" groups="analytic.group_analytic_accounting"/>
                        <field name="manual"/>
                        <field name="amount"/>
                        <field name="base" readonly="0"/>
                        <separator colspan="4" string="Tax Codes"/>
                        <field name="base_code_id"/>
                        <field name="base_amount"/>
                        <field name="tax_code_id"/>
                        <field name="tax_amount"/>
                        <field name="factor_base" invisible="True"/>
                        <field name="factor_tax" invisible="True"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="invoice_tree" model="ir.ui.view">
            <field name="name">account.invoice.tree</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <tree colors="blue:state == 'draft';black:state in ('proforma','proforma2','open');gray:state == 'cancel'" string="Invoice">
                    <field name="partner_id" groups="base.group_user"/>
                    <field name="commercial_partner_id" invisible="1"/>
                    <field name="date_invoice"/>
                    <field name="number"/>
                    <field name="reference" invisible="1"/>
                    <field name="name" invisible="1"/>
                    <field name="journal_id" invisible="1"/>
                    <field name="period_id" invisible="1" groups="account.group_account_user"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                    <field name="user_id" string="Responsible"/>
                    <field name="date_due"/>
                    <field name="origin"/>
                    <field name="currency_id" groups="base.group_multi_currency"/>
                    <field name="residual" sum="Residual Amount"/>
                    <field name="amount_untaxed" sum="Untaxed Amount"/>
                    <field name="amount_total" sum="Total Amount"/>
                    <field name="state"/>
                    <field name="type" invisible="context.get('type',True)"/>
                </tree>
            </field>
        </record>

        <record id="invoice_supplier_form" model="ir.ui.view">
            <field name="name">account.invoice.supplier.form</field>
            <field name="model">account.invoice</field>
            <field name="priority">2</field>
            <field name="arch" type="xml">
                <form string="Supplier Invoice">
                <header>
                        <button name="invoice_open" states="draft,proforma2" string="Validate" class="oe_highlight" groups="account.group_account_invoice"/>
                        <button name="%(action_account_invoice_refund)d" type='action' string='Ask Refund' states='open,paid' groups="account.group_account_invoice"/>
                        <button name="invoice_cancel" states="draft,proforma2" string="Cancel Invoice" groups="account.group_account_invoice"/>
                        <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" groups="account.group_account_invoice"/>
                        <button name='%(action_account_state_open)d' type='action' string='Re-Open' groups="account.group_account_invoice" attrs="{'invisible':['|', ('state','&lt;&gt;','paid'), ('reconciled', '=', True)]}" help="This button only appears when the state of the invoice is 'paid' (showing that it has been fully reconciled) and auto-computed boolean 'reconciled' is False (depicting that it's not the case anymore). In other words, the invoice has been dereconciled and it does not fit anymore the 'paid' state. You should press this button to re-open it and let it continue its normal process after having resolved the eventual exceptions it may have created."/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
                </header>
                <sheet string="Supplier Invoice">
                    <div class="oe_title">
                        <h1>
                            <label string="Draft Invoice" attrs="{'invisible': ['|',('state','&lt;&gt;','draft'), ('type','&lt;&gt;','in_invoice')]}"/>
                            <label string="Draft Refund" attrs="{'invisible': ['|',('state','&lt;&gt;','draft'), ('type','&lt;&gt;','in_refund')]}"/>
                            <label string="Invoice" attrs="{'invisible': ['|',('state', '=', 'draft'), ('type','&lt;&gt;','in_invoice')]}"/>
                            <label string="Refund" attrs="{'invisible': ['|',('state', '=', 'draft'), ('type','&lt;&gt;','in_refund')]}"/>
                            <field name="number" class="oe_inline"  attrs="{'invisible': [('state', '=', 'draft')]}"/>
                        </h1>
                    </div>
                    <field name="type" invisible="1"/>
                    <group>
                        <group>
                            <field string="Supplier" name="partner_id"
                              on_change="onchange_partner_id(type, partner_id, date_invoice, payment_term, partner_bank_id, company_id, context)"
                              context="{'default_customer': 0, 'search_default_supplier': 1, 'default_supplier': 1}"
                              domain="[('supplier', '=', True)]"/>
                            <field name="fiscal_position" options="{'no_create': True}"/>
                            <field name="origin"/>
                            <field name="supplier_invoice_number"/>
                            <label for="reference_type"/>
                            <div>
                                <field name="reference_type" class="oe_inline oe_edit_only"/>
                                <field name="reference" class="oe_inline"/>
                            </div>
                        </group>
                        <group>
                            <field name="date_invoice" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)" />
                            <field name="date_due"/>
                            <field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]"
                                name="account_id" groups="account.group_account_user"/>
                            <field name="internal_number" invisible="1"/>
                            <field name="journal_id" groups="account.group_account_user"
                                on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"
                                attrs="{'readonly':[('internal_number','!=',False)]}"/>
                            <field name="currency_id" groups="base.group_multi_currency"/>
                            <field name="check_total" groups="account.group_supplier_inv_check_total"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Invoice">
                            <field context="{'partner_id': partner_id, 'price_type': context.get('price_type') or False, 'type': type}" name="invoice_line">
                                <tree string="Invoice lines" editable="bottom">
                                    <field name="sequence" widget="handle" />
                                    <field name="product_id"
                                        on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                                    <field name="name"/>
                                    <field name="company_id" invisible="1"/>
                                    <field name="account_id" groups="account.group_account_user"
                                        domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]"
                                        on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
                                    <field name="account_analytic_id" groups="analytic.group_analytic_accounting"
                                        domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
                                    <field name="quantity"/>
                                    <field name="uos_id" groups="product.group_uom"
                                        on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                                    <field name="price_unit"/>
                                    <field name="discount" groups="sale.group_discount_per_so_line"/>
                                    <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
                                        domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
                                    <field name="price_subtotal"/>
                                </tree>
                            </field>
                            <group class="oe_subtotal_footer oe_right">
                                <field name="amount_untaxed" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <div>
                                    <label for="amount_tax"/>
                                    <button name="button_reset_taxes" states="draft,proforma2"
                                        string="(update)" class="oe_link oe_edit_only"
                                        type="object" help="Recompute taxes and total"/>
                                </div>
                                <field name="amount_tax" nolabel="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <field name="amount_total" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/>

                                <field name="residual" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <field name="reconciled" invisible="1"/>
                            </group>
                            <div style="width: 50%%">
                                <field name="tax_line">
                                    <tree editable="bottom" string="Taxes">
                                        <field name="name"/>
                                        <field name="account_id" groups="account.group_account_invoice"/>
                                        <field name="account_analytic_id" domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id)]" groups="analytic.group_analytic_accounting"/>
                                        <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
                                        <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>

                                        <field invisible="True" name="base_amount"/>
                                        <field invisible="True" name="tax_amount"/>
                                        <field name="factor_base" invisible="True"/>
                                        <field name="factor_tax" invisible="True"/>
                                    </tree>
                                </field>
                            </div>
                            <div class="oe_clear">
                                <label for="comment"/>
                            </div>
                            <field name="comment"/>
                        </page>
                        <page string="Other Info">
                            <group>
                                <group>
                                    <field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
                                    <field name="user_id" string="Responsible" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
                                    <field name="name" attrs="{'invisible': [('type', '=', 'in_invoice')]}"/>
                                    <field name="payment_term" options="{'no_create': True}"/>
                                </group>
                                <group>
                                    <field name="move_id" groups="account.group_account_user"/>
                                    <field name="period_id" domain="[('state', '=', 'draft'), ('company_id', '=', company_id)]" groups="account.group_account_user"/>
                                    <field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
                                </group>
                            </group>
                        </page>
                        <page string="Payments">
                            <field name="payment_ids">
                                <tree string="Payments">
                                    <field name="date" string="Payment Date"/>
                                    <field name="move_id"/>
                                    <field name="ref"/>
                                    <field name="name"/>
                                    <field name="journal_id"/>
                                    <field name="debit"/>
                                    <field name="credit"/>
                                    <field name="amount_currency"/>
                                    <field name="currency_id" groups="base.group_multi_currency"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
                </form>
            </field>
        </record>

        <record id="invoice_form" model="ir.ui.view">
            <field name="name">account.invoice.form</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <form string="Invoice">
                <header>
                    <button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
                    <button name="invoice_print" string="Print" type="object" attrs="{'invisible':['|',('sent','=',True), ('state', '!=', 'open')]}" class="oe_highlight" groups="base.group_user"/>
                    <button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/>
                    <button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/>
                    <button name="invoice_open" states="draft" string="Validate" class="oe_highlight" groups="base.group_user"/>
                    <button name="invoice_open" states="proforma2" string="Validate" groups="base.group_user"/>
                    <button name="invoice_proforma2" states="draft" string="PRO-FORMA" groups="account.group_proforma_invoices"/>
                    <button name="%(action_account_invoice_refund)d" type='action' string='Refund Invoice' states='open,proforma2,paid' groups="base.group_user"/>
                    <button name="invoice_cancel" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one"/>
                    <button name="action_cancel_draft" states="cancel" string="Reset to Draft" type="object" groups="base.group_user"/>
                    <button name='%(action_account_state_open)d' type='action' string='Re-Open' groups="account.group_account_invoice" attrs="{'invisible':['|', ('state','&lt;&gt;','paid'), ('reconciled', '=', True)]}" help="This button only appears when the state of the invoice is 'paid' (showing that it has been fully reconciled) and auto-computed boolean 'reconciled' is False (depicting that it's not the case anymore). In other words, the invoice has been dereconciled and it does not fit anymore the 'paid' state. You should press this button to re-open it and let it continue its normal process after having resolved the eventual exceptions it may have created."/>
                    <!--button name="%(account_invoices)d" string="Print Invoice" type="action" states="open,paid,proforma,sale,proforma2"/-->
                    <field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,open,paid" statusbar_colors='{"proforma":"blue","proforma2":"blue"}'/>
                </header>
                <sheet string="Invoice">
                    <h1>
                        <label string="Draft Invoice" attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_invoice')]}"/>
                        <label string="Draft Refund" attrs="{'invisible': ['|',('state','not in',('draft',)), ('type','&lt;&gt;','out_refund')]}"/>
                        <label string="Pro Forma Invoice" attrs="{'invisible': [('state','not in',('proforma','proforma2'))]}"/>
                        <label string="Invoice" attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_invoice')]}"/>
                        <label string="Refund" attrs="{'invisible': ['|',('state','in',('draft','proforma','proforma2')), ('type','&lt;&gt;','out_refund')]}"/>
                        <field name="number" readonly="1" class="oe_inline"/>
                    </h1>
                    <field name="type" invisible="1"/>
                    <group>
                        <group>
                            <field string="Customer" name="partner_id"
                                on_change="onchange_partner_id(type, partner_id, date_invoice, payment_term, partner_bank_id, company_id, context)"
                                context="{'search_default_customer':1, 'show_address': 1}"
                                options='{"always_reload": True}'
                                domain="[('customer', '=', True)]"/>
                            <field name="fiscal_position" options="{'no_create': True}" />
                        </group>
                        <group>
                            <field name="date_invoice" on_change="onchange_payment_term_date_invoice(payment_term, date_invoice)" />
                            <field name="internal_number" invisible="1"/>
                            <field name="journal_id" groups="account.group_account_user"
                                on_change="onchange_journal_id(journal_id)" options="{'no_create': True}"
                                attrs="{'readonly':[('internal_number','!=',False)]}"/>
                            <field domain="[('company_id', '=', company_id),('type','=', 'receivable')]"
                                name="account_id" groups="account.group_account_user"/>

                            <label for="currency_id" groups="base.group_multi_currency"/>
                            <div groups="base.group_multi_currency">
                                <field name="currency_id" class="oe_inline"/>
                                <button name="%(action_account_change_currency)d" type="action"
                                  class="oe_inline oe_link oe_edit_only"
                                  string="(change)"
                                  attrs="{'invisible':[('state','!=','draft')]}"
                                  groups="account.group_account_user"/>
                            </div>
                        </group>
                    </group>
                    <field name="sent" invisible="1"/>
                    <notebook colspan="4">
                        <page string="Invoice Lines">
                            <field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
                                <tree string="Invoice Lines" editable="bottom">
                                    <field name="sequence" widget="handle"/>
                                    <field name="product_id"
                                        on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                                    <field name="name"/>
                                    <field name="company_id" invisible="1"/>
                                    <field name="account_id" groups="account.group_account_user"
                                        domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]"
                                        on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
                                    <field name="account_analytic_id" groups="analytic.group_analytic_accounting"
                                        domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
                                    <field name="quantity"/>
                                    <field name="uos_id" groups="product.group_uom"
                                        on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
                                    <field name="price_unit"/>
                                    <field name="discount" groups="sale.group_discount_per_so_line"/>
                                    <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
                                        domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
                                    <field name="price_subtotal"/>
                                </tree>
                            </field>
                            <group class="oe_subtotal_footer oe_right">
                                <field name="amount_untaxed" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <div>
                                    <label for="amount_tax"/>
                                    <button name="button_reset_taxes" states="draft,proforma2"
                                        string="(update)" class="oe_link oe_edit_only"
                                        type="object" help="Recompute taxes and total"/>
                                </div>
                                <field name="amount_tax" nolabel="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <field name="amount_total" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <field name="residual" groups="account.group_account_user" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                <field name="reconciled" invisible="1"/>
                            </group>
                            <group>
                                    <field name="payment_term" class="oe_inline"/>
                            </group>
                            <div class="oe_clear">
                                <label for="comment"/>
                            </div>
                            <field name="comment" class="oe_inline" placeholder="Additional notes..."/>
                        </page>
                        <page string="Other Info">
                            <group col="4">
                                <group>
                                    <field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
                                    <field name="user_id" groups="base.group_user" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_invoice']}"/>
                                    <field domain="[('partner_id.ref_companies', 'in', [company_id])]" name="partner_bank_id"/>
                                    <field name="period_id" domain="[('state', '=', 'draft'), ('company_id', '=', company_id)]"
                                        groups="account.group_account_manager"
                                        string="Accounting Period"
                                        placeholder="force period"/>
                                    <field name="date_due"/>
                                </group>
                                <group>
                                    <field name="origin" groups="base.group_user"/>
                                    <field name="name"/>
                                    <field name="move_id" groups="account.group_account_user"/>
                                </group>
                            </group>
                            <field name="tax_line">
                                <tree editable="bottom" string="Taxes">
                                    <field name="name"/>
                                    <field name="account_id" groups="account.group_account_user"/>
                                    <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
                                    <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
                                    <field invisible="True" name="base_amount"/>
                                    <field invisible="True" name="tax_amount"/>
                                    <field name="factor_base" invisible="True"/>
                                    <field name="factor_tax" invisible="True"/>
                                </tree>
                            </field>
                        </page>
                        <page string="Payments" groups="base.group_user">
                            <field name="payment_ids">
                                <tree string="Payments">
                                    <field name="date"/>
                                    <field name="move_id"/>
                                    <field name="ref"/>
                                    <field name="name"/>
                                    <field name="journal_id" groups="base.group_user"/>
                                    <field name="debit"/>
                                    <field name="credit"/>
                                    <field name="amount_currency" groups="base.group_multi_currency"/>
                                    <field name="currency_id" groups="base.group_multi_currency"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
                </form>
            </field>
        </record>

        <!-- Custom reports (aka filters) -->
        <record id="filter_invoice_salespersons" model="ir.filters">
            <field name="name">By Salespersons</field>
            <field name="model_id">account.invoice</field>
            <field name="user_id" eval="False"/>
            <field name="context">{'group_by': ['date_invoice:month', 'user_id']}</field>
        </record>

        <record id="view_account_invoice_filter" model="ir.ui.view">
            <field name="name">account.invoice.select</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <search string="Search Invoice">
                    <field name="number" string="Invoice" filter_domain="['|','|','|', ('number','ilike',self), ('origin','ilike',self), ('supplier_invoice_number', 'ilike', self), ('partner_id', 'child_of', self)]"/>
                    <filter name="draft" string="Draft" domain="[('state','=','draft')]" help="Draft Invoices"/>
                    <filter name="proforma" string="Proforma" domain="[('state','=','proforma2')]" help="Proforma Invoices" groups="account.group_proforma_invoices"/>
                    <filter name="invoices" string="Invoices" domain="[('state','not in',['draft','cancel'])]" help="Proforma/Open/Paid Invoices"/>
                    <filter name="unpaid" string="Unpaid" domain="[('state','=','open')]" help="Unpaid Invoices"/>
                    <separator/>
                    <field name="partner_id" operator="child_of"/>
                    <field name="user_id" string="Salesperson"/>
                    <field name="period_id" string="Period"/>
                    <separator/>
                    <filter domain="[('user_id','=',uid)]" help="My Invoices"/>
                    <group expand="0" string="Group By">
                    	<filter name="group_by_partner_id" string="Partner" context="{'group_by':'partner_id'}"/>
                        <filter string="Salesperson" context="{'group_by':'user_id'}"/>
                        <filter string="Status" context="{'group_by':'state'}"/>
                        <separator/>
                        <filter string="Period" context="{'group_by':'period_id'}"/>
                        <filter string="Due Month" context="{'group_by':'date_due'}"/>
                    </group>
               </search>
            </field>
        </record>

        <record id="action_invoice_tree" model="ir.actions.act_window">
            <field name="name">Invoices</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field name="view_id" ref="invoice_tree"/>
            <field name="context">{'type':'out_invoice'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
        </record>

        <record id="action_invoice_refund_out_tree" model="ir.actions.act_window">
            <field name="name">Invoices</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field name="view_id" ref="invoice_tree"/>
            <field name="domain">[('type','in', ['out_invoice', 'out_refund']), ('state', 'not in', ['draft', 'cancel'])]</field>
            <field name="context">{'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
        </record>

        <record id="action_invoice_refund_out_tree_tree" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="act_window_id" ref="action_invoice_refund_out_tree"/>
        </record>

        <record id="action_invoice_refund_out_tree_form" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="invoice_form"/>
            <field name="act_window_id" ref="action_invoice_refund_out_tree"/>
        </record>

        <record id="action_invoice_tree_pending_invoice" model="ir.actions.act_window">
            <field name="name">Pending Invoice</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field name="view_id" ref="invoice_tree"/>
            <field name="context">{'type':'out_invoice'}</field>
            <field name="domain">[('state','=','draft')]</field>
           <!-- <field name="search_view_id" ref="view_account_invoice_filter"/>-->
        </record>

        <record id="action_invoice_tree_view1" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="act_window_id" ref="action_invoice_tree"/>
        </record>

        <record id="action_invoice_tree_view2" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="invoice_form"/>
            <field name="act_window_id" ref="action_invoice_tree"/>
        </record>

        <record id="action_invoice_tree1" model="ir.actions.act_window">
            <field name="name">Customer Invoices</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field eval="False" name="view_id"/>
            <field name="domain">[('type','=','out_invoice')]</field>
            <field name="context">{'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create a customer invoice.
              </p><p>
                Odoo's electronic invoicing allows to ease and fasten the
                collection of customer payments. Your customer receives the
                invoice by email and he can pay online and/or import it
                in his own system.
              </p><p>
                The discussions with your customer are automatically displayed at
                the bottom of each invoice.
              </p>
            </field>
        </record>


        <record id="action_invoice_tree1_view1" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="act_window_id" ref="action_invoice_tree1"/>
        </record>

        <record id="action_invoice_tree1_view2" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="invoice_form"/>
            <field name="act_window_id" ref="action_invoice_tree1"/>
        </record>

        <menuitem action="action_invoice_tree1" id="menu_action_invoice_tree1" parent="menu_finance_receivables"/>

        <record id="action_invoice_tree2" model="ir.actions.act_window">
            <field name="name">Supplier Invoices</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field eval="False" name="view_id"/>
            <field name="domain">[('type','=','in_invoice')]</field>
            <field name="context">{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to record a new supplier invoice.
              </p><p>
                You can control the invoice from your supplier according to
                what you purchased or received. Odoo can also generate
                draft invoices automatically from purchase orders or receipts.
              </p>
            </field>
        </record>
        <menuitem action="action_invoice_tree2" id="menu_action_invoice_tree2" parent="menu_finance_payables"/>

        <record id="action_invoice_tree3" model="ir.actions.act_window">
            <field name="name">Customer Refunds</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field eval="False" name="view_id"/>
            <field name="domain">[('type','=','out_refund')]</field>
            <field name="context">{'default_type':'out_refund', 'type':'out_refund', 'journal_type': 'sale_refund'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create a customer refund.
              </p><p>
                A refund is a document that credits an invoice completely or
                partially.
              </p><p>
                Instead of manually creating a customer refund, you
                can generate it directly from the related customer invoice.
              </p>
            </field>
        </record>

        <record id="action_invoice_tree3_view1" model="ir.actions.act_window.view">
            <field eval="1" name="sequence"/>
            <field name="view_mode">tree</field>
            <field name="act_window_id" ref="action_invoice_tree3"/>
        </record>

        <record id="action_invoice_tree3_view2" model="ir.actions.act_window.view">
            <field eval="2" name="sequence"/>
            <field name="view_mode">form</field>
            <field name="view_id" ref="invoice_form"/>
            <field name="act_window_id" ref="action_invoice_tree3"/>
        </record>
        <menuitem action="action_invoice_tree3" id="menu_action_invoice_tree3" parent="menu_finance_receivables"/>

        <record id="action_invoice_tree4" model="ir.actions.act_window">
            <field name="name">Supplier Refunds</field>
            <field name="res_model">account.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field eval="False" name="view_id"/>
            <field name="domain">[('type','=','in_refund')]</field>
            <field name="context">{'default_type': 'in_refund', 'type': 'in_refund', 'journal_type': 'purchase_refund'}</field>
            <field name="search_view_id" ref="view_account_invoice_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to register a refund you received from a supplier.
              </p><p>
                Instead of creating the supplier refund manually, you can generate
                refunds and reconcile them directly from the related supplier invoice.
              </p>
            </field>
        </record>
        <menuitem action="action_invoice_tree4" id="menu_action_invoice_tree4" parent="menu_finance_payables"/>

        <act_window
           id="act_account_journal_2_account_invoice_opened"
           name="Unpaid Invoices"
           context="{'search_default_journal_id': [active_id], 'search_default_unpaid':1, 'default_journal_id': active_id}"
           domain="[('journal_id','=', active_id)]"
           res_model="account.invoice"
           src_model="account.journal"/>

    </data>
</openerp>
