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

        <record id="view_account_analytic_account_list" model="ir.ui.view">
            <field name="name">account.analytic.account.list</field>
            <field name="model">account.analytic.account</field>
            <field name="type">tree</field>
            <field eval="8" name="priority"/>
            <field name="arch" type="xml">
                <tree toolbar="1" colors="red:(date&lt;current_date);black:(date&gt;=current_date);black:(date==False)" string="Analytic Accounts">
                    <field name="code"/>
                    <field name="complete_name"/>
                    <field name="quantity"/>
                    <field name="quantity_max"/>
                    <field name="date"/>
                </tree>
            </field>
        </record>

        <record id="view_account_analytic_account_search" model="ir.ui.view">
            <field name="name">account.analytic.account.search</field>
            <field name="model">account.analytic.account</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Analytic Account">
                    <group col="8" colspan="4">
                        <filter icon="terp-gtk-media-pause" string="Pending" domain="[('state','=','pending')]" help="Pending Accounts"/>
                        <filter icon="terp-camera_test" string="Current" domain="[('state','=','open')]" help="Current Accounts"/>
                        <separator orientation="vertical"/>
                        <filter icon="terp-go-today" string="Overdue Account" domain="[('date','&lt;',time.strftime('%%Y-%%m-%%d'))]" help="Analytic Accounts with a past deadline."/>
                        <separator orientation="vertical"/>
                        <field name="name" select="1"/>
                        <field name="code" select="1"/>
                        <field name="partner_id" select="1"/>
                        <field name="user_id" widget="selection"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group By...">
                        <filter string="Manager" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Associated Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Parent" icon="terp-folder-orange" domain="[]" context="{'group_by':'parent_id'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="view_account_analytic_account_tree" model="ir.ui.view">
            <field name="name">account.analytic.account.tree</field>
            <field name="model">account.analytic.account</field>
            <field name="type">tree</field>
            <field name="field_parent">child_ids</field>
            <field name="arch" type="xml">
                <tree colors="red:(date&lt;current_date);black:(date&gt;=current_date);black:(date==False)" string="Analytic account" toolbar="1">
                    <field name="name"/>
                    <field name="code"/>
                    <field name="quantity"/>
                    <field name="quantity_max"/>
                    <field name="debit"/>
                    <field name="credit"/>
                    <field name="balance"/>
                    <field name="currency_id" groups="base.group_extended"/>
                    <field name="date" invisible="1"/>
                    <field name="user_id" invisible="1"/>
                    <field name="partner_id" invisible="1"/>
                    <field name="parent_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="view_account_analytic_account_form" model="ir.ui.view">
            <field name="name">account.analytic.account.form</field>
            <field name="model">account.analytic.account</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Analytic account">
                    <group colspan="4" col="6">
                        <field name="name" select="1" colspan="4"/>
                        <field name="code" select="1"/>
                        <field name="parent_id" on_change="on_change_parent(parent_id)" groups="base.group_extended"/>
                        <field name="company_id" select="2" widget="selection" groups="base.group_multi_company"/>
                        <field name="type" select="2"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Account Data">
                            <field name="partner_id" select="1"/>
                            <newline/>
                            <field name="date_start"/>
                            <field name="date" select="2"/>
                            <newline/>
                            <field name="quantity_max"/>
                            <field name="user_id"/>
                        </page>
                        <page string="Description">
                            <field colspan="4" name="description" nolabel="1"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record id="action_account_analytic_account_form" model="ir.actions.act_window">
            <field name="name">Analytic Accounts</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">account.analytic.account</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,graph,form</field>
            <field name="view_id" ref="view_account_analytic_account_tree"/>
            <field name="search_view_id" ref="account.view_account_analytic_account_search"/>
        </record>
        <menuitem action="action_account_analytic_account_form" id="account_analytic_def_account" parent="menu_analytic_accounting" groups="analytic.group_analytic_accounting"/>

        <record id="act_account_renew_view" model="ir.actions.act_window">
            <field name="name">Accounts to Renew</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">account.analytic.account</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('date','&lt;',time.strftime('%Y-%m-%d %H:%M:%S'))]</field>
            <field name="filter" eval="True"/>
        </record>

        <record id="action_account_analytic_account_tree2" model="ir.actions.act_window">
            <field name="name">Chart of Analytic Accounts</field>
            <field name="res_model">account.analytic.account</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="view_account_analytic_account_tree"/>
            <field name="domain">[('parent_id','=',False)]</field>
            <field name="help">Analytic Charts of Accounts allows you to access to reports by analytic accounts (or cost accounts) . From this menu you can access to analytic balance, a report that relates the analytic accounts to the general accounts. It is useful for analyzing the profitability of projects, giving you the profitability of a project for the different operations that you used to carry out the project.</field>
        </record>

        <menuitem groups="analytic.group_analytic_accounting" id="next_id_40" name="Analytic" parent="account.menu_finance_generic_reporting" sequence="4"/>

        <record id="view_account_analytic_line_form" model="ir.ui.view">
            <field name="name">account.analytic.line.form</field>
            <field name="model">account.analytic.line</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Analytic Entry">
                    <group colspan="4" col="6">
                        <field name="name"/>
                        <field name="ref"/>
                        <field name="account_id"/>
                        <field name="journal_id"/>
                        <field name="date"/>
                        <field name="company_id" groups="base.group_multi_company"/>
                    </group>
                    <group colspan="2" col="4">
                        <separator string="Amount" colspan="4"/>
                        <field name="amount" colspan="4"/>
                        <field name="amount_currency" colspan="2"/>
                        <field name="currency_id" colspan="2" nolabel="1"/>
                    </group>
                    <group colspan="2" col="4">
                        <separator string="Product Information" colspan="4"/>
                        <field name="product_id" colspan="4"/>
                        <field name="unit_amount" colspan="2"/>
                        <field name="product_uom_id" colspan="2" nolabel="1"/>
                    </group>
                    <group colspan="2" col="2" groups="base.group_extended">
                        <separator string="General Accounting" colspan="2"/>
                        <field name="general_account_id"/>
                        <field name="move_id" readonly="1"/>
                    </group>
                </form>
            </field>
        </record>
        <record id="view_account_analytic_line_tree" model="ir.ui.view">
            <field name="name">account.analytic.line.tree</field>
            <field name="model">account.analytic.line</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree editable="top" string="Analytic Entries">
                    <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                    <field name="name"/>
                    <field name="journal_id"/>
                    <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" sum="Total quantity"/>
                    <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/>
                    <field domain="[('type','=','normal')]" name="account_id" groups="base.group_extended"/>
                    <field invisible="True" name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                    <field name="amount" sum="Total amount"/>
                    <field name="general_account_id"/>
                    <field name="ref"/>
                    <field name="currency_id" />
                    <field name="amount_currency" />
                    <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" groups="base.group_multi_company"/>
                </tree>
            </field>
        </record>
        <record id="view_account_analytic_line_filter" model="ir.ui.view">
            <field name="name">account.analytic.line.select</field>
            <field name="model">account.analytic.line</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Analytic Lines">
                    <group col='6' colspan='4'>
                        <filter string="Sales" domain="[('journal_id.type','=','sale')]" icon="terp-sale" help="Analytic Journal Items related to a sale journal."/>
                        <filter string="Purchases" domain="[('journal_id.type','=','purchase')]" icon="terp-purchase" help="Analytic Journal Items related to a purchase journal."/>
                        <separator orientation="vertical"/>
                        <filter icon="terp-go-today" string="Overdue Accounts" domain="[('account_id.date','&lt;',time.strftime('%%Y-%%m-%%d'))]" help="Analytic Journal Items related to accounts having a past deadline."/>
                        <separator orientation="vertical"/>
                        <field name="date" select="1"/>
                        <field name="name" select="1"/>
                        <field name="account_id" select="1"/>
                        <field name="user_id" widget="selection"/>
                    </group>
                    <newline/>
                    <group string="Group By..." expand="0">
                        <filter string="Analytic Account" context="{'group_by':'account_id'}" groups="base.group_extended" icon="terp-folder-blue"/>
                        <filter string="Analytic Journal" context="{'group_by':'journal_id'}" icon="terp-folder-orange"/>
                        <separator orientation="vertical"/>
                        <filter string="General Account" context="{'group_by':'general_account_id'}" icon="terp-folder-green"/>
                        <separator orientation="vertical"/>
                        <filter string="Product" context="{'group_by':'product_id'}" icon="terp-accessories-archiver"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Extended options...">
                        <field name="journal_id" widget="selection"/>
                        <field name="product_id" widget="selection"/>
                        <field name="amount" select="1"/>
                    </group>
                </search>
            </field>
        </record>
        <record id="action_account_analytic_line_form" model="ir.actions.act_window">
            <field name="name">Analytic Entries</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">account.analytic.line</field>
            <field name="view_type">form</field>
            <field name="context">{"search_default_user_id":uid}</field>
            <field name="view_id" ref="view_account_analytic_line_tree"/>
        </record>

        <!-- Entries by Line -->

        <record id="action_account_tree1" model="ir.actions.act_window">
            <field name="name">Analytic Entries</field>
            <field name="res_model">account.analytic.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('account_id','child_of',[active_id])]</field>
            <field name="context">{'account_id':active_id}</field>
            <field name="search_view_id" ref="view_account_analytic_line_filter"/>
        </record>
        <record id="ir_open_account_analytic_account" model="ir.values">
            <field eval="'tree_but_open'" name="key2"/>
            <field eval="'account.analytic.account'" name="model"/>
            <field name="name">Open Account Tree</field>
            <field eval="'ir.actions.act_window,%d'%action_account_tree1" name="value"/>
            <field eval="True" name="object"/>
        </record>

        <record id="account_analytic_line_extended_form" model="ir.ui.view">
            <field name="name">account.analytic.line.extended_form</field>
            <field name="model">account.analytic.line</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Project line">
                    <field name="name"/>
                    <field name="account_id" groups="base.group_extended"/>
                    <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                    <field name="journal_id"/>
                    <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                    <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/>
                    <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                    <field invisible="True" name="general_account_id"/>
                    <field name="amount"/>
                    <field name="currency_id" />
                    <field name="amount_currency" />
                    <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
                </form>
            </field>
        </record>
        <record id="action_account_analytic_account_line_extended_form" model="ir.actions.act_window">
            <field name="name">account.analytic.line.extended</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">account.analytic.line</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="account_analytic_line_extended_form"/>
        </record>

        #
        # Analytic Journal
        #

        <record id="view_account_analytic_journal_tree" model="ir.ui.view">
            <field name="name">account.analytic.journal.tree</field>
            <field name="model">account.analytic.journal</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Analytic Journal">
                    <field name="code"/>
                    <field name="name"/>
                    <field name="type"/>
                </tree>
            </field>
        </record>

        <record id="view_analytic_journal_search" model="ir.ui.view">
            <field name="name">account.analytic.journal.search</field>
            <field name="model">account.analytic.journal</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Analytic Journals">
                  <group>
                      <field name="code"/>
                      <field name="name"/>
                      <field name="type"/>
                  </group>
                  <newline/>
                    <group expand="0" string="Group By...">
                        <filter string="Type" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'type'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="view_account_analytic_journal_form" model="ir.ui.view">
            <field name="name">account.analytic.journal.form</field>
            <field name="model">account.analytic.journal</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Analytic Journal">
                    <field name="name" select="1"/>
                    <field name="code" select="1"/>
                    <field name="type" select="2"/>
                    <field name="active" select="2"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                </form>
            </field>
        </record>
        <record id="action_account_analytic_journal_form" model="ir.actions.act_window">
            <field name="name">Analytic Journals</field>
            <field name="res_model">account.analytic.journal</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,search</field>
            <field name="search_view_id" ref="view_analytic_journal_search" />
        </record>
        <menuitem groups="analytic.group_analytic_accounting" action="action_account_analytic_journal_form" id="account_def_analytic_journal" parent="menu_analytic_accounting" sequence="5"/>

        #
        # Open journal entries
        #

        <record id="action_account_analytic_journal_open_form" model="ir.actions.act_window">
            <field name="name">Analytic Journal Items</field>
            <field name="res_model">account.analytic.line</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem groups="analytic.group_analytic_accounting" action="action_account_analytic_journal_open_form" id="account_analytic_journal_entries" parent="menu_finance_entries"/>

        #
        # Reporting
        #

        <record id="action_account_analytic_journal_tree" model="ir.actions.act_window">
            <field name="name">Print Analytic Journals</field>
            <field name="res_model">account.analytic.journal</field>
            <field name="view_type">tree</field>
            <field name="help">To print an analytics (or costs) journal for a given period. The report give code, move name, account number, general amount and analytic amount.</field>
        </record>
        <menuitem groups="analytic.group_analytic_accounting" action="action_account_analytic_journal_tree" id="account_analytic_journal_print" parent="account.next_id_40"/>

        #
        # Statistics
        #

        <record id="report_hr_timesheet_invoice_journal_form" model="ir.ui.view">
            <field name="name">report.hr.timesheet.invoice.journal.form</field>
            <field name="model">report.hr.timesheet.invoice.journal</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Analytic Entries Stats">
                    <field name="name" select="1"/>
                    <field name="account_id" select="1"/>
                    <field name="journal_id" select="2"/>
                </form>
            </field>
        </record>


        <record id="report_hr_timesheet_invoice_journal_tree" model="ir.ui.view">
            <field name="name">report.hr.timesheet.invoice.journal.tree</field>
            <field name="model">report.hr.timesheet.invoice.journal</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Analytic Entries Stats">
                    <field name="name"/>
                    <field name="month"/>
                    <field name="account_id"/>
                    <field name="journal_id"/>
                    <field name="quantity"/>
                    <field name="revenue"/>
                    <field name="cost"/>
                </tree>
            </field>
        </record>

        <record id="report_hr_timesheet_invoice_journal_graph" model="ir.ui.view">
            <field name="name">report.hr.timesheet.invoice.journal.graph</field>
            <field name="model">report.hr.timesheet.invoice.journal</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Analytic Entries Stats" type="bar">
                    <field name="name"/>
                    <field name="month"/>
                    <field name="cost" operator="+"/>
                    <field name="revenue" operator="+"/>
                    <field group="True" name="journal_id"/>
                </graph>
            </field>
        </record>

        <record id="report_hr_timesheet_invoice_journal_search" model="ir.ui.view">
            <field name="name">report.hr.timesheet.invoice.journal.search</field>
            <field name="model">report.hr.timesheet.invoice.journal</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Analytic Entries Stats">
                    <group col="8" colspan="4">
                        <filter icon="terp-go-year" string="This Year" domain="[('name','=',time.strftime('%%Y'))]" help="Sale journal in this year"/>
                           <filter icon="terp-go-month" string="This Month" domain="[('month','=',time.strftime('%%m'))]" help="Sale journal in this month"/>
                           <separator orientation="vertical"/>
                        <field name="name" select="1"/>
                           <field name="month" select="1"/>
                        <field name="account_id" select="1"/>
                    </group>
                </search>
            </field>
        </record>

        <act_window 
            context="{'search_default_account_id': [active_id], 'search_default_user_id': False}"
            id="act_acc_analytic_acc_5_report_hr_timesheet_invoice_journal" 
            name="All Analytic Entries" 
            res_model="account.analytic.line" 
            src_model="account.analytic.account" 
            view_mode="tree,form" 
            view_type="form"/>

        <record id="view_account_journal_1" model="ir.ui.view">
            <field name="name">account.journal.form.1</field>
            <field name="model">account.journal</field>
            <field name="inherit_id" ref="account.view_account_journal_form"/>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <field name="currency" position="after">
                    <field name="analytic_journal_id"/>
                </field>
            </field>
        </record>

     <record id="analytic_accounts_graph" model="ir.ui.view">
            <field name="name">analytic.accounts.graph</field>
            <field name="model">account.analytic.account</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="Analytic Account Statistics" type="bar">
                    <field name="complete_name"/>
                    <field name="balance" operator="+"/>
                </graph>
            </field>
     </record>

    </data>
</openerp>
