<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Tree view -->
        <record id="view_l10n_es_aeat_report_tree" model="ir.ui.view">
            <field name="name">l10n_es.aeat.report.tree</field>
            <field name="model">l10n.es.aeat.report</field>
            <field name="arch" type="xml">
                <tree string="AEAT report">
                    <field name="name"/>
                    <field name="fiscalyear_id"/>
                    <field name="period_type"/>
                    <field name="state"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                </tree>
            </field>
        </record>

        <!-- Form view -->
        <record id="view_l10n_es_aeat_report_form" model="ir.ui.view">
            <field name="name">l10n_es.aeat.report.form</field>
            <field name="model">l10n.es.aeat.report</field>
            <field name="arch" type="xml">
                <form string="AEAT report">
                    <header>
                        <button name="button_calculate" type="object" string="Calculate" states="draft" icon="terp-stock_format-scientific"/>
                        <button name="button_recalculate" type="object" string="Recalculate" states="calculated" icon="gtk-execute"/>
                        <button name="button_confirm" string="Confirm" type="object" states="calculated" icon="gtk-ok"/>
                        <button name="%(action_wizard_aeat_export)d" type="action" string="Export to BOE" states="done,posted" icon="gtk-execute"/>
                        <button name="button_recover" string="Draft" type="object" states="cancelled" icon="gtk-undo"/>
                        <button name="button_open_move"
                                string="Show move"
                                type="object"
                                states="posted"
                                />
                        <button name="button_post"
                                string="Create move"
                                help="This button creates the regularization move for the selected report"
                                type="object"
                                class="oe_highlight"
                                attrs="{'invisible': ['|', ('state', '!=', 'done'), ('allow_posting', '=', False)]}"
                                />
                        <button name="button_cancel" string="Cancel" type="object" states="calculated,done" icon="gtk-cancel"/>
                        <button name="button_unpost" string="Cancel" type="object" states="posted" icon="gtk-cancel"/>
                        <field name="state"
                               widget="statusbar"
                               statusbar_visible="draft,calculated,done,cancelled"
                               statusbar_colors='{"cancelled": "red", "done": "blue", "posted": "blue"}'
                               />
                    </header>
                    <sheet>
                        <field name="allow_posting" invisible="1"/>
                        <field name="number" invisible="1"/>
                        <field name="model" invisible="1"/>
                        <h1>
                            <label string="Report "/>
                            <field name="name" class="oe_inline" readonly="1"/>
                        </h1>
                        <group string="Declaración"
                               colspan="4"
                               name="group_declaration"
                                >
                            <group>
                                <field name="company_vat" required="1"/>
                                <field name="fiscalyear_id"/>
                                <field name="period_type"/>
                                <field name="periods" widget="many2many_tags"/>
                                <field name="export_config"
                                       groups="base.group_no_one"/>
                            </group>
                            <group>
                                <field name="journal_id"
                                       attrs="{'invisible': [('allow_posting', '=', False)]}"
                                        />
                                <field name="counterpart_account"
                                       attrs="{'invisible': [('allow_posting', '=', False)]}"
                                        />
                                <field name="representative_vat"/>
                                <field name="support_type"/>
                                <field name="calculation_date" readonly="1"/>
                                <field name="partner_bank_id"/>
                                <field name="company_id"
                                       required="1"
                                       groups="base.group_multi_company"
                                        />
                            </group>
                            <group string="Contact data"
                                   name="group_contact_data"
                                    >
                                <field name="contact_name"/>
                                <field name="contact_phone"/>
                            </group>
                            <group string="Other parameters"
                                   name="group_other_parameters">
                                <field name="type"/>
                                <field name="previous_number"
                                       attrs="{'invisible': [('type', '==', 'N')], 'required': [('type', 'in', ('S', 'C'))]}"
                                        />
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="view_l10n_es_aeat_report_search" model="ir.ui.view">
            <field name="name">AEAT Model (search)</field>
            <field name="model">l10n.es.aeat.report</field>
            <field name="arch" type="xml">
                <search string="AEAT">
                    <filter string="Draft" domain="[('state','=','draft')]" help="Draft models"/>
                    <filter string="In process" domain="[('state', '=', 'calculated')]" help="In process models"/>
                    <filter string="Done" domain="[('state', '=', 'done')]" help="Confirmed models"/>
                    <filter string="Cancelled" domain="[('state', '=', 'cancelled')]" help="Cancelled models"/>
                    <filter string="Fiscal year" domain="[]" context="{'group_by':'fiscalyear_id'}"/>
                    <filter string="Company" domain="[]" context="{'group_by': 'company_id'}" groups="base.group_multi_company"/>
                </search>
            </field>
        </record>

    </data>
</openerp>
