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

		<record model="ir.ui.view" id="view_report_account_invoice_tree">
			<field name="name">report.account.invoice.product.tree</field>
			<field name="model">report.account.invoice.product</field>
			<field name="type">tree</field>
			<field name="arch" type="xml">
				<tree string="Invoices by product">
					<field name="date"/>
	                <field name="year" invisible="1" />
                	<field name="month" invisible="1"/>
                	<field name="day" invisible="1"/>
					<field name="type"/>
					<field name="state"/>
					<field name="product_id" invisible="1" />
					<field name="partner_id"/>
					<field name="categ_id" invisible="1" />
					<field name="amount"/>
					<field name="cost_price"/>
					<field name="margin"/>
					<field name="quantity"/>
				</tree>
			</field>
		</record>
		
         <record id="view_report_account_invoice_filter" model="ir.ui.view">
            <field name="name">account.invoice.product.filter</field>
            <field name="model">report.account.invoice.product</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Margin">
                    <group col="10" colspan="4">
						<filter icon="terp-go-year" string="This Year" domain="[('year','=',time.strftime('%%Y'))]" help="All Months Sales by Margin"/>
						<filter icon="terp-go-month" string="This Month" domain="[('month','=',time.strftime('%%m'))]" help="This Months Sales by Margin"/>
						<separator orientation="vertical"/>
						<filter string="Draft" icon="terp-document-new" domain="[('state','=','draft')]" help="Draft Invoices"/>
                   		<filter string="Pro-forma" icon="terp-check" domain="[('state','=','proforma')]" help="Pro-forma Invoices"/>
                   		<filter string="Current" icon="terp-check" domain="[('state', '=' ,'open')]" help="open Invoices"/>
	                	<filter string="Done" icon="terp-dialog-close" domain="[('state','=','paid')]" help="Done Invoices"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Extended Filters..." groups="base.group_extended">
                        <field name="date" string="Date Invoiced"/>
                        <separator orientation="vertical"/>
                        <field name="partner_id" widget="selection"/>
                        <separator orientation="vertical"/>
                        <field name="amount" />
                        <field name="state"/>
                        <newline/>
                        <field name="product_id"/>
                        <field name="categ_id"/>
                    </group>
                    <newline/>
                    <group expand="1" string="Group By..." colspan="4" col="10">
                        <filter string="Partner" icon="terp-partner" context="{'group_by':'partner_id'}"/>
                        <separator orientation="vertical"/>
	                    <filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
	                    <filter string="Category" icon="terp-stock_symbol-selection" context="{'group_by':'categ_id'}"/>
 						<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
 						<separator orientation="vertical"/>
	                    <filter string="Day" icon="terp-go-month" context="{'group_by':'day'}"/>
    	                <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
        	            <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
                    </group>
                </search>
            </field>
        </record>
        
        <record id="view_report_account_invoice_graph" model="ir.ui.view">
             <field name="name">report.account.invoice.product.graph</field>
             <field name="model">report.account.invoice.product</field>
             <field name="type">graph</field>
             <field name="arch" type="xml">
                 <graph string="Invoice by Partner" type="pie">
                	<field name="partner_id"/>
					<field name="margin"/>
					<field name="amount"/>
                 </graph>
             </field>
        </record>
                
		<record id="action_report_account_invoice_report" model="ir.actions.act_window">
	        <field name="name">Invoice Analysis</field>
	        <field name="res_model">report.account.invoice.product</field>
	        <field name="view_type">form</field>
	        <field name="view_mode">tree,graph</field>
	        <field name="context">{"search_default_At Date":1,'group_by_no_leaf':1,'group_by':[]}</field>
	        <field name="search_view_id" ref="view_report_account_invoice_filter"/>
	    </record>		

		<menuitem name="Invoice Report" id="menu_report_account_invoice_product" parent="account.menu_finance_reporting"/>

		<menuitem name="Invoice" id="menu_report_account_invoice_reoirt" parent="menu_report_account_invoice_product" action="action_report_account_invoice_report" groups="account.group_account_manager"/>
	</data>
</openerp>
