<openerp>
<data>

    <!--
        Asset Category
     -->

    <record model="ir.ui.view" id="view_account_asset_category_form">
        <field name="name">account.asset.category.form</field>
        <field name="model">account.asset.category</field>
        <field name="arch" type="xml">
            <form string="Asset category" version="7.0">
                <group>
                    <group>
                        <field name="name"/>
                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                    </group>
                    <group>
                        <field name="journal_id"/>
                        <field name="account_asset_id" on_change="onchange_account_asset(account_asset_id)"/>
                        <field name="account_depreciation_id"/>
                        <field name="account_expense_depreciation_id"/>
                    </group>
                    <group string="Depreciation Dates">
                        <field name="method_time"/>
                        <field name="method_number" attrs="{'invisible':[('method_time','=','end')], 'required':[('method_time','=','number')]}"/>
                        <field name="method_period"/>
                        <field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','=','number')]}"/>
                    </group>
                    <group string="Depreciation Method">
                        <field name="method"/>
                        <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
                        <field name="prorata"/>
                        <field name="open_asset"/>
                    </group>
                    <group groups="analytic.group_analytic_accounting" string="Analytic Information">
                        <field name="account_analytic_id"/>
                    </group>
                </group>
                <separator string="Notes"/>
                <field name="note"/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_category_tree">
        <field name="name">account.asset.category.tree</field>
        <field name="model">account.asset.category</field>
        <field name="arch" type="xml">
            <tree string="Asset category">
                <field name="name"/>
                <field name="journal_id"/>
                <field name="method"/>
                <field name="company_id" groups="base.group_multi_company"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_category_search">
        <field name="name">account.asset.category.search</field>
        <field name="model">account.asset.category</field>
        <field name="arch" type="xml">
            <search string="Search Asset Category">
                <field name="name" string="Asset Category"/>
                <field name="journal_id"/>
            </search>
        </field>
    </record>

    <!--
        Asset
     -->

    <record model="ir.ui.view" id="view_account_asset_asset_form">
        <field name="name">account.asset.asset.form</field>
        <field name="model">account.asset.asset</field>
        <field name="arch" type="xml">
            <form string="Asset" version="7.0">
                <header>
                    <button name="validate" states="draft" string="Confirm Asset" type="object" class="oe_highlight"/>
                    <button name="set_to_close" states="open" string="Set to Close" type="object" class="oe_highlight"/>
                    <button name="set_to_draft" states="open" string="Set to Draft" type="object" />
                    <field name="state" widget="statusbar" statusbar_visible="draft,open"/>
                </header>
                <sheet>
                    <div class="oe_button_box oe_right">
                        <button name="open_entries" string="Entries" type="object" class="oe_inline"/>
                    </div>
                    <div class="oe_title">
                        <label for="name" class="oe_edit_only"/>
                        <h1>
                            <field name="name" class="oe_inline"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="category_id" on_change="onchange_category_id(category_id)"/>
                            <field name="code"/>
                            <field name="parent_id"/>
                        </group>
                        <group>
                            <field name="purchase_date"/>
                            <field name="currency_id" groups="base.group_multi_currency"/>
                            <field name="company_id" widget="selection" groups="base.group_multi_company" on_change="onchange_company_id(company_id)"/>
                        </group>
                    </group>
                    <notebook colspan="4">
                        <page string="General">
                            <group>
                                <group>
                                    <field name="purchase_value" widget="monetary" options="{'currency_field': 'currency_id'}" on_change="onchange_purchase_salvage_value(purchase_value, salvage_value)"/>
                                    <field name="salvage_value" widget="monetary" options="{'currency_field': 'currency_id'}" on_change="onchange_purchase_salvage_value(purchase_value, salvage_value)"/>
                                    <field name="value_residual" widget="monetary" options="{'currency_field': 'currency_id'}"/>
                                    <field name="partner_id"/>
                                </group>
                                <group>
                                    <field name="method"/>
                                    <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
                                    <label for="method_time"/>
                                    <div>
                                        <field name="method_time" on_change="onchange_method_time(method_time)" class="oe_inline"/>
                                        <button name="%(action_asset_modify)d" states="open" string="Change Duration" type="action" icon="terp-stock_effects-object-colorize" class="oe_inline" colspan="1"/>
                                    </div>
                                    <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
                                    <field name="method_number" attrs="{'invisible':[('method_time','=','end')], 'required':[('method_time','=','number')]}"/>
                                    <field name="method_period"/>
                                    <field name="method_end" attrs="{'required': [('method_time','=','end')], 'invisible':[('method_time','=','number')]}"/>
                                </group>
                            </group>
                        </page>
                        <page string="Depreciation Board">
                            <field name="depreciation_line_ids" mode="tree">
                                <tree string="Depreciation Lines" colors="blue:(move_check == False);black:(move_check == True)">
                                    <field name="depreciation_date"/>
                                    <field name="sequence" invisible="1"/>
                                    <field name="depreciated_value" readonly="1"/>
                                    <field name="amount"/>
                                    <field name="remaining_value" readonly="1"/>
                                    <field name="move_check"/>
                                    <field name="parent_state" invisible="1"/>
                                    <button name="create_move" attrs="{'invisible':['|',('move_check','!=',False),('parent_state','!=','open')]}" icon="gtk-execute" string="Create Move" type="object"/>
                                </tree>
                                <form string="Depreciation Lines"> 
                                    <group>
                                        <group>
                                            <field name="asset_id" invisible="1"/>
                                            <field name="parent_state" invisible="1"/>
                                            <field name="name"/>
                                            <field name="amount"/>
                                            <field name="move_id"/>
                                            <field name="move_check"/>
                                            <field name="parent_state" invisible="1"/>
                                        </group>
                                        <group>
                                            <field name="sequence"/>
                                            <field name="depreciation_date"/>
                                            <field name="depreciated_value" readonly="1"/>
                                            <field name="remaining_value" readonly="1"/>
                                        </group>
                                    </group>
                                </form>
                            </field>
                            <button type="object" name="compute_depreciation_board" string="Compute" icon="terp-stock_format-scientific" colspan="2" attrs="{'invisible':[('state','=','close')]}"/>
                        </page>
                        <page string="History">
                            <field name="account_move_line_ids" readonly="1"/>
                            <field name="history_ids" readonly="1"/>
                        </page>
                        <page string="Notes">
                            <field name="note" placeholder="Add an internal note here..."/>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_asset_tree">
        <field name="name">account.asset.asset.tree</field>
        <field name="model">account.asset.asset</field>
        <field name="field_parent">child_ids</field>
        <field name="arch" type="xml">
            <tree string="Assets" colors="blue:(state == 'draft');grey:(state == 'close')">
                <field name="name"/>
                <field name="category_id"/>
                <field name="purchase_date"/>
                <field name="partner_id"/>
                <field name="purchase_value"/>
                <field name="value_residual"/>
                <field name="currency_id" groups="base.group_multi_currency"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="state"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_asset_hierarchy_tree">
        <field name="name">account.asset.asset.hierarchy</field>
        <field name="model">account.asset.asset</field>
        <field name="field_parent">child_ids</field>
        <field name="arch" type="xml">
            <tree string="Assets">
                <field name="name"/>
                <field name="code"/>
                <field name="category_id"/>
                <field name="purchase_date"/>
                <field name="purchase_value"/>
                <field name="value_residual"/>
                <field name="currency_id" groups="base.group_multi_currency"/>
                <field name="company_id" groups="base.group_multi_company"/>
                <field name="state"/>
            </tree>
        </field>
    </record>

    <record id="view_account_asset_search" model="ir.ui.view">
        <field name="name">account.asset.asset.search</field>
        <field name="model">account.asset.asset</field>
        <field name="arch" type="xml">
            <search string="Account Asset">
                <field name="name" string="Asset"/>
                <field name="purchase_date"/>
                <filter icon="terp-check" string="Current" domain="[('state','in', ('draft','open'))]" help="Assets in draft and open states"/>
                <filter icon="terp-dialog-close" string="Closed" domain="[('state','=', 'close')]" help="Assets in closed state"/>
                <field name="category_id"/>
                <field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
            </search>
        </field>
    </record>

    <!--
        Asset History
     -->

    <record model="ir.ui.view" id="view_account_asset_history_form">
        <field name="name">account.asset.history.form</field>
        <field name="model">account.asset.history</field>
        <field name="arch" type="xml">
            <form string="Asset History" version="7.0">
                <group>
                    <group>
                        <field name="name"/>
                        <field name="date"/>
                        <field name="user_id"/>
                    </group>
                    <group>
                        <field name="method_time"/>
                        <field name="method_number" attrs="{'invisible':[('method_time','=','end')]}"/>
                        <field name="method_period"/>
                        <field name="method_end" attrs="{'invisible':[('method_time','=','number')]}"/>
                    </group>
                </group>
                <separator string="Notes"/>
                <field name="note"/>
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_account_asset_history_tree">
        <field name="name">account.asset.history.tree</field>
        <field name="model">account.asset.history</field>
        <field name="arch" type="xml">
            <tree string="Asset history">
                <field name="date"/>
                <field name="name"/>
                <field name="user_id"/>
                <field name="method_time"/>
                <field name="method_number"/>
                <field name="method_period"/>
                <field name="method_end"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_account_asset_asset_tree">
        <field name="name">Asset Hierarchy</field>
        <field name="res_model">account.asset.asset</field>
        <field name="view_type">tree</field>
        <field name="domain">[('parent_id','=',False)]</field>
        <field name="view_id" ref="view_account_asset_asset_hierarchy_tree"/>
    </record>

    <record id="view_account_move_line_form_inherit" model="ir.ui.view">
        <field name="name">Journal Items (form)</field>
        <field name="model">account.move.line</field>
        <field name="inherit_id" ref="account.view_move_line_form"/>
        <field name="arch" type="xml">
            <field name="statement_id" position="after">
                <field name="asset_id"/>
            </field>
        </field>
    </record>

    <record id="view_account_move_line_filter_inherit" model="ir.ui.view">
        <field name="name">Journal Items (Search)</field>
        <field name="model">account.move.line</field>
        <field name="inherit_id" ref="account.view_account_move_line_filter"/>
        <field name="arch" type="xml">
            <field name="account_id" position="after">
                <field name="asset_id"/>
            </field>
        </field>
    </record>

    <menuitem id="menu_finance_assets" name="Assets" parent="account.menu_finance" sequence="9"/>
    <menuitem parent="menu_finance_assets" id="menu_action_account_asset_asset_tree"
        sequence="100"
        action="action_account_asset_asset_tree"/>

    <record model="ir.actions.act_window" id="action_account_asset_asset_form">
        <field name="name">Assets</field>
        <field name="res_model">account.asset.asset</field>
        <field name="view_type">form</field>
        <field name="view_id" ref="view_account_asset_asset_tree"/>
        <field name="search_view_id" ref="view_account_asset_search"/>
    </record>

    <menuitem parent="menu_finance_assets" id="menu_action_account_asset_asset_form" action="action_account_asset_asset_form"/>

    <act_window id="act_entries_open" name="Entries" res_model="account.move.line" src_model="account.asset.asset" context="{'search_default_asset_id': [active_id], 'default_asset_id': active_id}"/>

    <menuitem id="menu_finance_config_assets" name="Assets" parent="account.menu_finance_configuration" sequence="25"/>
    <record model="ir.actions.act_window" id="action_account_asset_asset_list_normal">
        <field name="name">Asset Categories</field>
        <field name="res_model">account.asset.category</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem parent="menu_finance_config_assets" id="menu_action_account_asset_asset_list_normal" action="action_account_asset_asset_list_normal"/>

</data>
</openerp>
