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

        <menuitem id="menu_audit" name="Audit" parent="base.menu_reporting" sequence="50" groups="base.group_system"/>

        <!-- Audittrail Rule -->

        <record model="ir.ui.view" id="view_audittrail_rule_form">
            <field name="name">audittrail.rule.form</field>
            <field name="model">audittrail.rule</field>
            <field name="arch" type="xml">
                <form string="AuditTrail Rule" version="7.0">
                   <header>
                       <button string="_Subscribe" name="subscribe" icon="gtk-ok"
                           type="object" states="draft"/>
                       <button string="UnSubscribe" name="unsubscribe" icon="gtk-cancel"
                           type="object" states="subscribed"/>
                       <field name="state" widget="statusbar"/>
                   </header>
                 <sheet>
                    <group col="4">
                        <field name="name" required="1"/>
                        <field name="object_id"/>
                        <field name="log_read"/>
                        <field name="log_write"/>
                        <field name="log_unlink"/>
                        <field name="log_create"/>
                        <field name="log_action"/>
                        <field name="log_workflow"/>
                        <separator string="Users (if User is not added then it will applicable for all users)"  colspan="4"/>
                        <field name="user_id" colspan="4" nolabel="1"/>
                        <field name="action_id" colspan="4" readonly="1" groups="base.group_no_one"/>
                    </group>
                   </sheet>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="view_audittrail_rule_tree">
            <field name="name">audittrail.rule.tree</field>
            <field name="model">audittrail.rule</field>
            <field name="arch" type="xml">
                <tree colors="blue:state == 'draft';black:state == 'subscribed'" string="AuditTrail Rules">
                    <field name="name"/>
                    <field name="object_id"/>
                    <field name="log_read"/>
                    <field name="log_write"/>
                    <field name="log_unlink"/>
                    <field name="log_create"/>
                    <field name="log_action"/>
                    <field name="log_workflow"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <record id="view_audittrail_rule_search" model="ir.ui.view">
            <field name="name">audittrail.rule.search</field>
            <field name="model">audittrail.rule</field>
            <field name="arch" type="xml">
                <search string="Search Audittrail Rule">
                    <field name="name" string="Audittrail Rule"/>
                    <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft  Rule"/>
                    <filter icon="terp-camera_test" string="Subscribed" domain="[('state','=','subscribed')]" help="Subscribed Rule"/>
                    <field name="object_id" string="Model"/>
                    <group expand="0" string="Group By...">
                        <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_audittrail_rule_tree">
            <field name="name">Audit Rules</field>
            <field name="res_model">audittrail.rule</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{'search_default_draft': 1}</field>
            <field name="search_view_id" ref="view_audittrail_rule_search"/>
        </record>

        <menuitem id="menu_action_audittrail_rule_tree" parent="menu_audit" action="action_audittrail_rule_tree"/>

        <!-- AuditTrail Log -->

        <record model="ir.ui.view" id="view_audittrail_log_form">
            <field name="name">audittrail.log.form</field>
            <field name="model">audittrail.log</field>
            <field name="arch" type="xml">
                <form string="AuditTrail Logs" version="7.0">
                 <sheet>
                    <group col="4">
                        <field name="timestamp" required="1" readonly="1"/>
                        <field name="user_id" readonly="1"/>
                        <field name="method" readonly="1"/>
                        <field name="name" readonly="1"/>
                        <field name="res_id" readonly="1"/>
                        <field name="object_id" readonly="1"/>
                    </group>
                    <field name="line_ids" mode="tree"
                        widget="one2many_list" readonly="1">
                        <form string="Log Lines" version="7.0">
                            <group col="4">
                            <field name="field_id" colspan="4"
                                readonly="1"/>
                            <newline/>
                            <field name="field_description" colspan="4"
                                readonly="1"/>
                            <newline/>
                            <separator string="Old Value : "
                                colspan="2"/>
                            <separator string="New Value : "
                                colspan="2"/>
                            <newline/>
                            <field name="old_value" nolabel="1"
                                colspan="2" readonly="1"/>
                            <field name="new_value" nolabel="1"
                                colspan="2" readonly="1"/>
                            <newline/>
                            <separator string="Old Value Text : "
                                colspan="2"/>
                            <separator string="New Value Text: "
                                colspan="2"/>
                            <newline/>
                            <field name="old_value_text" nolabel="1"
                                colspan="2" readonly="1"/>
                            <field name="new_value_text" nolabel="1"
                                colspan="2" readonly="1"/>
                            </group>
                        </form>
                        <tree string="Log Lines">
                            <field name="field_description"/>
                            <field name="old_value_text"/>
                            <field name="new_value_text"/>
                        </tree>
                    </field>
                  </sheet>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="view_audittrail_log_tree">
            <field name="name">audittrail.log.tree</field>
            <field name="model">audittrail.log</field>
            <field name="arch" type="xml">
                <tree string="AuditTrail Logs" create="false">
                    <field name="timestamp"/>
                    <field name="name"/>
                    <field name="object_id"/>
                    <field name="method"/>
                    <field name="user_id"/>
                </tree>
            </field>
        </record>

       <record id="view_audittrail_log_search" model="ir.ui.view">
            <field name="name">audittrail.log.search</field>
            <field name="model">audittrail.log</field>
            <field name="arch" type="xml">
                <search string="Search Audittrail Log">
                    <field name="name" string="Audittrail Log"/>
                    <field name="object_id" string="Model"/>
                    <field name="user_id"/>
                    <group expand="0" string="Group By...">
                        <filter string="User" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Object" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'object_id'}"/>
                        <filter string="Date" icon="terp-go-month" domain="[]" context="{'group_by':'timestamp'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_audittrail_log_tree">
            <field name="name">Audit Logs</field>
            <field name="res_model">audittrail.log</field>
            <field name="view_type">form</field>
            <field name="search_view_id" ref="view_audittrail_log_search"/>
        </record>

        <menuitem id="menu_audit_logs" name="Audit Logs" parent="menu_audit" action="action_audittrail_log_tree"/>

    </data>
</openerp>
