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

        <!-- Balance by account type -->

        <record id="view_crm_case_user_graph" model="ir.ui.view">
            <field name="name">report.account.receivable.graph</field>
            <field name="model">report.account.receivable</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Accounts by type" type="bar">
                    <field name="name"/>
                    <field name="balance" operator="+"/>
                </graph>
            </field>
        </record>
        <record id="view_crm_case_user_tree" model="ir.ui.view">
            <field name="name">report.account.receivable.tree</field>
            <field name="model">report.account.receivable</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Accounts by type">
                    <field name="name"/>
                    <field name="type"/>
                    <field name="balance"/>
                    <field name="debit"/>
                    <field name="credit"/>
                </tree>
            </field>
        </record>
        <record id="view_crm_case_user_form" model="ir.ui.view">
            <field name="name">report.account.receivable.form</field>
            <field name="model">report.account.receivable</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Accounts by type">
                    <field name="name" select="1"/>
                    <field name="type" select="1"/>
                </form>
            </field>
        </record>

        <record id="action_account_receivable_graph" model="ir.actions.act_window">
            <field name="name">Balance by Type of Account</field>
            <field name="res_model">report.account.receivable</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph</field>
        </record>

        <!-- Report for Aged Receivable -->

        <record id="view_aged_recv_graph" model="ir.ui.view">
            <field name="name">report.aged.receivable.graph</field>
            <field name="model">report.aged.receivable</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Aged Receivable" type="bar">
                    <field name="name"/>
                    <field name="balance" operator="+"/>
                </graph>
            </field>
        </record>

        <record id="view_aged_recv_tree" model="ir.ui.view">
            <field name="name">report.aged.receivable.tree</field>
            <field name="model">report.aged.receivable</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Aged Receivable">
                    <field name="name" select="1"/>
                    <field name="balance" select="2"/>
                </tree>
            </field>
        </record>

        <record id="action_aged_receivable_graph" model="ir.actions.act_window">
            <field name="name">Aged Receivable</field>
            <field name="res_model">report.aged.receivable</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph,tree</field>
        </record>

        <!-- Created Invoice for random activities of service dashboard -->

        <record id="board_view_created_invoice" model="ir.ui.view">
            <field name="name">report.invoice.created.tree</field>
            <field name="model">report.invoice.created</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree colors="blue:state in ('draft');black:state in ('proforma','proforma2','open');gray:state in('paid','cancel') " string="Invoices">
                   	<field name="create_date" select="1"/>
                    <field name="name" select="1"/>
                    <field name="type"/>
                    <field name="number"/>
                    <field name="partner_id"/>
                    <field name="amount_untaxed" sum="Untaxed Amount"/>
                    <field name="amount_total" sum="Total Amount"/>
                    <field name="currency_id"/>
                    <field name="date_invoice"/>
                    <field name="date_due" select="1"/>
                    <field name="residual"/>
                    <field name="state" select="2"/>
                    <field name="origin"/>
                </tree>
            </field>
        </record>

	    <record id="action_view_created_invoice_dashboard" model="ir.actions.act_window">
		    <field name="name">Invoices Created Within Past 15 Days</field>
		    <field name="res_model">report.invoice.created</field>
		    <field name="view_type">form</field>
		    <field name="view_mode">tree,form</field>
		    <field name="view_id" ref="board_view_created_invoice"/>
	    </record>

	    <record id="view_report_account_sales_tree" model="ir.ui.view">
            <field name="name">report.account.sales.tree</field>
            <field name="model">report.account.sales</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Sales by Account">
                    <field name="name" select="1"/>
                    <field name="month" select="1"/>
                    <field name="product_id"/>
                    <field name="account_id"/>
                    <field name="quantity"/>
                    <field name="amount_total"/>
                    <field name="currency_id"/>
                </tree>
            </field>
        </record>

        <record id="view_report_account_sales_graph" model="ir.ui.view">
             <field name="name">report.account.sales.graph</field>
             <field name="model">report.account.sales</field>
             <field name="type">graph</field>
             <field name="arch" type="xml">
                 <graph string="Sales by Account" type="pie">
                     <field name="account_id"/>
                     <field name="amount_total"/>
                 </graph>
             </field>
        </record>

        <record id="view_report_account_sales_search" model="ir.ui.view">
            <field name="name">report.account.sales.search</field>
            <field name="model">report.account.sales</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Sales by Account">
					<filter icon="terp-go-year" string="This Year" domain="[('name','=',time.strftime('%%Y'))]" help="This year's Sales by type"/>
					<filter icon="terp-go-month" string="This Month" domain="[('month','=',time.strftime('%%m'))]" help="This months' Sales by type"/>
					<separator orientation="vertical"/>
					<field name="name" select="1"/>
					<field name="month" select="1"/>
               </search>
            </field>
        </record>

        <record id="action_report_account_sales_tree_all" model="ir.actions.act_window">
            <field name="name">Sales by Account</field>
            <field name="res_model">report.account.sales</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph,tree</field>
            <field name="search_view_id" ref="view_report_account_sales_search"/>
        </record>

	    <record id="view_report_account_type_sales_tree" model="ir.ui.view">
            <field name="name">report.account_type.sales.tree</field>
            <field name="model">report.account_type.sales</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Sales by Account type">
                    <field name="name"/>
                    <field name="month"/>
                    <field name="period_id"/>
                    <field name="product_id"/>
                    <field name="user_type"/>
                    <field name="quantity"/>
                    <field name="amount_total"/>
                    <field name="currency_id"/>
                </tree>
            </field>
        </record>

        <record id="view_report_account_type_sales_form" model="ir.ui.view">
            <field name="name">report.account_type.sales.form</field>
            <field name="model">report.account_type.sales</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <tree string="Sales by Account type">
                    <field name="name" select="1"/>
                    <field name="month" select="1"/>
                    <field name="product_id" select="1"/>
                </tree>
            </field>
        </record>

        <record id="view_report_account_type_sales_graph" model="ir.ui.view">
             <field name="name">report.account_type.sales.graph</field>
             <field name="model">report.account_type.sales</field>
             <field name="type">graph</field>
             <field name="arch" type="xml">
                 <graph string="Sales by Account" type="pie">
                     <field name="user_type"/>
                     <field name="amount_total"/>
                 </graph>
             </field>
        </record>

		<record id="view_report_account_type_sales_search" model="ir.ui.view">
            <field name="name">report.account_type.sales.search</field>
            <field name="model">report.account_type.sales</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Sales by Account">
					<filter icon="terp-go-year" string="This Year" domain="[('name','=',time.strftime('%%Y'))]" help="All Months Sales by type"/>
					<filter icon="terp-go-month" string="This Month" domain="[('month','=',time.strftime('%%m'))]" help="This Months Sales by type"/>
					<separator orientation="vertical"/>
					<field name="name" select="1"/>
					<field name="month" select="1"/>
               </search>
            </field>
        </record>

        <record id="action_report_account_type_sales_tree_all" model="ir.actions.act_window">
            <field name="name">Sales by Account Type</field>
            <field name="res_model">report.account_type.sales</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph,tree</field>
            <field name="search_view_id" ref="view_report_account_type_sales_search"/>
        </record>

    </data>
</openerp>
