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

        <record model="ir.ui.view" id="mis_report_view_tree">
            <field name="name">mis.report.view.tree</field>
            <field name="model">mis.report</field>
            <field name="arch" type="xml">
                <tree string="MIS Reports">
                    <field name="name"/>
                    <field name="description"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="mis_report_view_form">
            <field name="name">mis.report.view.form</field>
            <field name="model">mis.report</field>
            <field name="arch" type="xml">
                <form string="MIS Report" version="7.0">
                <sheet>
                    <group col="2">
                        <field name="name"/>
                        <field name="description"/>
                        <field name="style_id"/>
                    </group>
                    <group string="Sub KPI's">
                         <field name="subkpi_ids" nolabel="1" colspan="2">
                            <tree string="Sub KPI's" editable="bottom">
                                <field name="sequence" widget="handle"/>
                                <field name="description"/>
                                <field name="name"/>
                            </tree>
                        </field>
                    </group>
                    <group string="Queries">
                        <field name="query_ids" nolabel="1" colspan="2">
                            <tree string="Queries" editable="bottom">
                                <field name="name"/>
                                <field name="model_id"/>
                                <field name="field_ids" domain="[('model_id', '=', model_id)]" widget="many2many_tags"/>
                                <field name="field_names"/>
                                <field name="aggregate"/>
                                <field name="date_field" domain="[('model_id', '=', model_id), ('ttype', 'in', ('date', 'datetime'))]"/>
                                <field name="domain"/>
                            </tree>
                        </field>
                    </group>
                    <group string="KPI's">
                        <field name="kpi_ids" nolabel="1" colspan="2">
                            <tree string="KPI's">
                                <field name="sequence" widget="handle"/>
                                <field name="description"/>
                                <field name="name"/>
                                <field name="type"/>
                                <field name="compare_method" attrs="{'invisible': [('type', '=', 'str')]}"/>
                                <field name="multi"/>
                                <field name="expression"/>
                            </tree>
                        </field>
                    </group>
                    <group col="2" string="Legend (for kpi expressions)">
                        <group>
                            <label colspan="2" string="Expressions are of the form &lt;field&gt;&lt;mode&gt;[accounts][domain]"/>
                            <label colspan="2" string="Possible values for 'field' can be:"/>
                            <group>
                                <label colspan="2" string="* bal for balance (debit - credit)"/>
                                <label colspan="2" string="* crd for credit"/>
                                <label colspan="2" string="* deb for debit"/>
                            </group>
                            <label colspan="2" string="Possible values for 'mode' are:"/>
                            <group>
                                <label colspan="2" string="* nothing or p: variation over the period"/>
                                <label colspan="2" string="* i: at the beginning of the period"/>
                                <label colspan="2" string="* e: at the end of the period"/>
                            </group>
                            <label colspan="2" string="'accounts' is a comma-separated list of account codes, possibly containing %% wildcards"/>
                            <label colspan="2" string="'domain' is an optional filter on move lines (eg to filter on analytic accounts or journal)"/>
                       </group>
                       <group>
                            <label colspan="2" string="Examples"/>
                            <group>
                                <label colspan="2" string="* bal[70]: variation of the balance of account 70 over the period (it is the same as balp[70]);"/>
                                <label colspan="2" string="* bali[70,60]: initial balance of accounts 70 and 60;"/>
                                <label colspan="2" string="* bale[1%%]: balance of accounts starting with 1 at end of period."/>
                            </group>
                        </group>
                    </group>
                </sheet>
                </form>
            </field>
        </record>

        <record id="mis_report_view_kpi_form" model="ir.ui.view">
            <field name="name">mis.report.view.kpi.form</field>
            <field name="model">mis.report.kpi</field>
            <field name="arch" type="xml">
                <form string="MIS Report KPI" version="7.0">
                    <group col="4">
                        <field name="description"/>
                        <field name="name"/>
                        <field name="type"/>
                        <field name="compare_method"/>
                        <field name="style_id"/>
                        <field name="style_expression"/>
                        <!--<field name="sequence" />-->
                        <field name="report_id" invisible="1"/>
                    </group>
                    <group string="Expression">
                        <field name="multi"/>
                        <field name="expression_ids" colspan="4" nolabel="1"
                               delete="0" create="0"
                               attrs="{'invisible': [('multi', '=', False)]}">
                            <tree editable="bottom">
                                <field name="subkpi_id" domain="[('report_id', '=', parent.report_id)]"/>
                                <field name="name"/>
                            </tree>
                        </field>
                        <field name="expression" colspan="4" nolabel="1"
                               attrs="{'invisible': [('multi', '=', True)],
                                       'readonly': [('multi', '=', True)]}"/>
                    </group>
                    <group col="4" string="Auto expand">
                        <field name="auto_expand_accounts"/>
                        <field name="auto_expand_accounts_style_id"
                               attrs="{'invisible': [('auto_expand_accounts', '!=', True)]}"/>
                    </group>
                    <group col="2" string="Legend (for kpi expressions)">
                        <group>
                            <label colspan="2" string="Expressions are of the form &lt;field&gt;&lt;mode&gt;[accounts][domain]"/>
                            <label colspan="2" string="Possible values for 'field' can be:"/>
                            <group>
                                <label colspan="2" string="* bal for balance (debit - credit)"/>
                                <label colspan="2" string="* crd for credit"/>
                                <label colspan="2" string="* deb for debit"/>
                            </group>
                            <label colspan="2" string="Possible values for 'mode' are:"/>
                            <group>
                                <label colspan="2" string="* nothing or p: variation over the period"/>
                                <label colspan="2" string="* i: at the beginning of the period"/>
                                <label colspan="2" string="* e: at the end of the period"/>
                            </group>
                            <label colspan="2" string="'accounts' is a comma-separated list of account codes, possibly containing %% wildcards"/>
                            <label colspan="2" string="'domain' is an optional filter on move lines (eg to filter on analytic accounts or journal)"/>
                       </group>
                       <group>
                            <label colspan="2" string="Examples"/>
                            <group>
                                <label colspan="2" string="* bal[70]: variation of the balance of account 70 over the period (it is the same as balp[70]);"/>
                                <label colspan="2" string="* bali[70,60]: initial balance of accounts 70 and 60;"/>
                                <label colspan="2" string="* bale[1%%]: balance of accounts starting with 1 at end of period."/>
                            </group>
                        </group>
                    </group>

                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="mis_report_view_action">
            <field name="name">MIS Report Templates</field>
            <field name="view_id" ref="mis_report_view_tree"/>
            <field name="res_model">mis.report</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem id="mis_report_conf_menu" parent="account.menu_finance_configuration" name="MIS Reporting" sequence="90"/>
        <menuitem id="mis_report_view_menu" parent="mis_report_conf_menu" name="MIS Report Templates" action="mis_report_view_action" sequence="21"/>

    </data>
</openerp>