<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Attachment -->
        <record id="view_attachment_form" model="ir.ui.view">
            <field name="model">ir.attachment</field>
            <field name="arch" type="xml">
                <form string="Attachments" version="7.0">
                   <sheet>
                    <label for="name" class="oe_edit_only"/>
                    <h1>
                        <field name="name"/>
                    </h1>
                    <group>
                        <group string="Data">
                            <field name="type"/>
                            <field name="datas" filename="datas_fname" attrs="{'invisible':[('type','=','url')]}"/>
                            <field name="datas_fname" invisible="1" attrs="{'invisible':[('type','=','url')]}" class="oe_inline oe_right"/>
                            <field name="url" widget="url" attrs="{'invisible':[('type','=','binary')]}"/>
                        </group>
                        <group string="Attached To">
                            <field name="res_model"/>
                            <field name="res_id"/>
                            <field name="res_name"/>
                            <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                        </group>
                        <group groups="base.group_no_one" string="History">
                            <label for="create_uid" string="Creation"/>
                            <div name="creation_div">
                                <field name="create_uid" readonly="1" class="oe_inline"/> on 
                                <field name="create_date" readonly="1" class="oe_inline"/>
                            </div>
                        </group>
                        <group name="description_group" string="Description" colspan="4">
                            <field name="description" nolabel="1"/>
                        </group>
                    </group>
                  </sheet>
                </form>
            </field>
        </record>
        <record id="view_attachment_tree" model="ir.ui.view">
            <field name="model">ir.attachment</field>
            <field name="arch" type="xml">
                <tree string="Attachments">
                    <field name="name"/>
                    <field name="datas_fname"/>
                    <field name="type" invisible="1"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="create_uid"/>
                    <field name="create_date"/>
                </tree>
            </field>
        </record>
        <record id="view_attachment_search" model="ir.ui.view">
            <field name="model">ir.attachment</field>
            <field name="arch" type="xml">
                <search string="Attachments">
                    <field name="name" filter_domain="['|', ('name','ilike',self), ('datas_fname','ilike',self)]" string="Attachment"/>
                    <field name="create_date"/>
                    <filter icon="terp-stage"
                        string="URL"
                        domain="[('type','=','url')]"/>
                    <filter icon="terp-stock_align_left_24"
                        string="Binary"
                        domain="[('type','=','binary')]"/>
                    <separator/>
                    <filter name="my_documents_filter" 
                        string="My Document(s)"
                        icon="terp-personal"
                        domain="[('create_uid','=',uid)]"
                        help="Filter on my documents"/>
                    <field name="create_uid"/>
                    <field name="type"/>
                    <group expand="0" string="Group By...">
                        <filter string="Owner" icon="terp-personal" domain="[]" context="{'group_by':'create_uid'}"/>
                        <filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type'}" groups="base.group_no_one"/>
                        <filter string="Company" icon="terp-gtk-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <filter string="Month" help="Creation Month" icon="terp-go-month" domain="[]" context="{'group_by':'create_date'}"/>
                    </group>
                </search>
            </field>
        </record>
        <record id="action_attachment" model="ir.actions.act_window">
            <field name="name">Attachments</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">ir.attachment</field>
            <field name="view_type">form</field>
            <field name="view_id" eval="False"/>
            <field name="search_view_id" ref="view_attachment_search"/>
        </record>
        <menuitem action="action_attachment" id="menu_action_attachment" parent="base.next_id_4"/>

    </data>
</openerp>
