<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <record id="view_account_invoice_report_tree" model="ir.ui.view">
        <field name="name">account.invoice.report.tree</field>
        <field name="model">account.invoice.report</field>
        <field name="arch" type="xml">
            <tree colors="blue:state == 'draft';gray:state in ('cancel','paid');black:state in ('proforma','proforma2')" create="false" string="Invoices Analysis">
                <field name="date" invisible="1"/>
                <field name="user_id" invisible="1"/>
                <field name="year" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="type" invisible="1"/>
                <field name="company_id" invisible="1"/>
                <field name="partner_id" invisible="1"/>
                <field name="product_id" invisible="1"/>
                <field name="uom_name" invisible="not context.get('set_visible',False)"/>
                <field name="categ_id" invisible="1"/>
                <field name="state" invisible="1"/>
                <field name="period_id" invisible="1"/>
                <field name="currency_id" invisible="1"/>
                <field name="journal_id" invisible="1"/>
                <field name="partner_bank_id" invisible="1"/>
                <field name="date_due" invisible="1"/>
                <field name="account_id" invisible="1"/>
                <field name="account_line_id" invisible="1"/>
                <field name="nbr" sum="# of Lines"/>
                <field name="product_qty" sum="Qty"/>
                <!-- <field name="reconciled"  sum="# Reconciled"/> -->
                <field name="price_total" sum="Total Without Tax"/>
            </tree>
        </field>
    </record>

    <record id="view_account_invoice_report_graph" model="ir.ui.view">
         <field name="name">account.invoice.report.graph</field>
         <field name="model">account.invoice.report</field>
         <field name="arch" type="xml">
             <graph string="Invoices Analysis" type="bar">
                 <field name="product_id"/>
                 <field name="price_total"/>
             </graph>
         </field>
    </record>

    <record id="view_account_invoice_report_search" model="ir.ui.view">
        <field name="name">account.invoice.report.search</field>
        <field name="model">account.invoice.report</field>
        <field name="arch" type="xml">
            <search string="Invoices Analysis">
                <field name="date"/>
                <filter icon="terp-go-year" string="Year" name="year" domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="year"/>
                <separator/>
                <filter string="Draft" icon="terp-document-new" domain="[('state','=','draft')]" help = "Draft Invoices"/>
                <filter string="Pro-forma" icon="terp-gtk-media-pause" domain="['|', ('state','=','proforma'),('state','=','proforma2')]" help = "Pro-forma Invoices"/>
                <filter string="Invoiced" name="current" icon="terp-check" domain="[('state','not in', ('draft','cancel'))]" help = "Open and Paid Invoices"/>
                <separator/>
                <filter icon="terp-personal" string="Customer" name="customer" domain="['|', ('type','=','out_invoice'),('type','=','out_refund')]" help="Customer Invoices And Refunds"/>
                <filter icon="terp-personal" string="Supplier" domain="['|', ('type','=','in_invoice'),('type','=','in_refund')]" help="Supplier Invoices And Refunds"/>
                <separator/>
                <filter icon="terp-dolar" string="Invoice" domain="['|', ('type','=','out_invoice'),('type','=','in_invoice')]" help="Customer And Supplier Invoices"/>
                <filter icon="terp-dolar_ok!" string="Refund" domain="['|', ('type','=','out_refund'),('type','=','in_refund')]" help="Customer And Supplier Refunds"/>
                <field name="partner_id" operator="child_of"/>
                <field name="user_id" />
                <field name="categ_id" filter_domain="[('categ_id', 'child_of', self)]"/>
                <group expand="1" string="Group By...">
                    <filter string="Partner" name="partner" icon="terp-partner" context="{'group_by':'partner_id','residual_visible':True}"/>
                    <filter string="Salesperson" name='user' icon="terp-personal" context="{'group_by':'user_id'}"/>
                    <filter string="Due Date" icon="terp-go-today" context="{'group_by':'date_due'}"/>
                    <filter string="Period" icon="terp-go-month" context="{'group_by':'period_id'}" name="period"/>
                    <filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id','set_visible':True,'residual_invisible':True}"/>
                    <filter string="Category of Product" name="category_product" icon="terp-stock_symbol-selection" context="{'group_by':'categ_id','residual_invisible':True}"/>
                    <filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    <filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'type'}"/>
                    <filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
                    <filter string="Account" icon="terp-folder-orange" context="{'group_by':'account_line_id'}"/>
                    <filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                    <filter string="Day" name="day" icon="terp-go-today" context="{'group_by':'day'}" help="Group by Invoice Date"/>
                    <filter string="Month" name="month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of Invoice Date"/>
                    <filter string="Year" name="group_year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of Invoice Date"/>
                </group>
            </search>
        </field>
    </record>

    <record id="action_account_invoice_report_all" model="ir.actions.act_window">
        <field name="name">Invoices Analysis</field>
        <field name="res_model">account.invoice.report</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,graph</field>
        <field name="context">{'search_default_period':1,'search_default_current':1, 'search_default_year': 1, 'search_default_category_product':1, 'search_default_customer':1, 'group_by':[], 'group_by_no_leaf':1,}</field>
        <field name="search_view_id" ref="view_account_invoice_report_search"/>
        <field name="help">From this report, you can have an overview of the amount invoiced to your customer. The tool search can also be used to personalise your Invoices reports and so, match this analysis to your needs.</field>

    </record>

    <menuitem action="action_account_invoice_report_all" id="menu_action_account_invoice_report_all" parent="account.menu_finance_reporting" sequence="0"/>

    <act_window
        id="act_account_invoice_partner_relation"
        name="Monthly Turnover"
        groups="group_account_manager"
        context="{'search_default_partner_id':[active_id], 'search_default_month':1,'search_default_user':1,'group_by_no_leaf':1,'group_by':[]}"
        res_model="account.invoice.report"
        src_model="res.partner"/>

</data>
</openerp>
