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

    <record id="view_attachment_queue_form" model="ir.ui.view">
        <field name="model">attachment.queue</field>
        <field name="inherit_id" ref="base.view_attachment_form" />
        <field name="mode">primary</field>
        <field name="arch" type="xml">
            <xpath expr="/form/*" position="before">
                <header>
                    <button
                        name="button_manual_run"
                        states="pending,failed"
                        string="Manual run"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="button_reschedule"
                        states="done,failed"
                        string="Reschedule"
                        type="object"
                        class="oe_highlight"
                    />
                    <button
                        name="set_done"
                        states="pending,failed"
                        string="Set to Done"
                        type="object"
                    />
                </header>
            </xpath>
            <field name="url" position="after">
                <field name="date_done" />
                <field name="state" />
                <field name="file_type" />
            </field>
            <group name="description_group" position="after">
                <group name="state_message" string="Error" colspan="4">
                    <field name="state_message" nolabel="1" colspan="2" />
                </group>
            </group>
            <xpath expr="//sheet" position="after">
                <div class="oe_chatter">
                    <field name="activity_ids" widget="mail_activity" />
                </div>
            </xpath>
        </field>
    </record>

    <record id="view_attachment_queue_tree" model="ir.ui.view">
        <field name="model">attachment.queue</field>
        <field name="arch" type="xml">
            <tree default_order='create_date desc'>
                <field name="create_date" />
                <field name="name" />
                <field name="file_type" />
                <field name="type" />
                <field name="state" />
            </tree>
        </field>
    </record>

    <record id="view_attachment_queue_search" model="ir.ui.view">
    <field name="model">attachment.queue</field>
    <field name="arch" type="xml">
        <search string="Attachments">
            <field
                    name="name"
                    filter_domain="[('name','ilike',self)]"
                    string="Attachment"
                />
            <field name="create_date" />
            <filter name="url" string="URL" domain="[('type','=','url')]" />
            <filter name="binary" string="Binary" domain="[('type','=','binary')]" />
            <separator />
            <filter
                    name="my_documents_filter"
                    string="My Document(s)"
                    domain="[('create_uid','=',uid)]"
                    help="Filter on my documents"
                />
            <field name="create_uid" />
            <field name="type" />
            <filter
                    string="Pending"
                    name="pending"
                    domain="[('state', '=', 'pending')]"
                />
            <filter string="Failed" name="failed" domain="[('state', '=', 'failed')]" />
            <filter string="Done" name="done" domain="[('state', '=', 'done')]" />
            <group expand="0" string="Group By">
                <filter
                        string="Owner"
                        name="owner"
                        domain="[]"
                        context="{'group_by':'create_uid'}"
                    />
                <filter
                        string="Type"
                        name="type"
                        domain="[]"
                        context="{'group_by':'type'}"
                        groups="base.group_no_one"
                    />
                <filter
                        string="Company"
                        name="company"
                        domain="[]"
                        context="{'group_by':'company_id'}"
                        groups="base.group_multi_company"
                    />
                <filter
                        string="Creation Month"
                        name="creation_month"
                        domain="[]"
                        context="{'group_by':'create_date'}"
                    />
                <filter
                        string="State"
                        name="state"
                        domain="[]"
                        context="{'group_by': 'state'}"
                    />
                <filter
                        string="File type"
                        name="file_type"
                        domain="[]"
                        context="{'group_by': 'file_type'}"
                    />
            </group>
        </search>
    </field>
    </record>

    <record id="action_attachment_queue" model="ir.actions.act_window">
        <field name="name">Attachments Queue</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">attachment.queue</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" eval="False" />
        <field name="search_view_id" ref="view_attachment_queue_search" />
    </record>

    <record id="act_open_attachment_que_view_tree" model="ir.actions.act_window.view">
        <field eval="10" name="sequence" />
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_attachment_queue_tree" />
        <field name="act_window_id" ref="action_attachment_queue" />
    </record>

    <record id="act_open_attachment_que_view_form" model="ir.actions.act_window.view">
        <field eval="10" name="sequence" />
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_attachment_queue_form" />
        <field name="act_window_id" ref="action_attachment_queue" />
    </record>

    <menuitem
        id="menu_attachment_queue"
        parent="queue_job.menu_queue_job_root"
        sequence="20"
        action="action_attachment_queue"
    />

</odoo>
