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

<odoo>
    <record id="certificate_certificate_view_search" model="ir.ui.view">
        <field name="name">certificate_certificate_view_search.inherit.l10n_es_edi_sii</field>
        <field name="model">certificate.certificate</field>
        <field name="inherit_id" ref="certificate.certificate_certificate_view_search"/>
        <field name="arch" type="xml">
            <filter name="scope_general" position="after">
                <filter string="SII" name="scope_sii" domain="[('scope','=','sii')]" help="SII certificates"/>
            </filter>
        </field>
    </record>

    <record id="l10n_es_edi_sii_certificate_action" model="ir.actions.act_window">
        <field name="name">Certificates for SII EDI invoices on Spain</field>
        <field name="res_model">certificate.certificate</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'scope': 'sii', 'search_default_scope_sii': 1}</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">Create the first certificate</p>
        </field>
    </record>

    <record id="certificate_certificate_view_form" model="ir.ui.view">
        <field name="name">certificate_certificate_view_form.inherit.l10n_es_edi_sii</field>
        <field name="model">certificate.certificate</field>
        <field name="inherit_id" ref="certificate.certificate_certificate_view_form"/>
        <field name="arch" type="xml">
            <field name="scope" position="attributes">
                <attribute name="invisible" add="not (country_code == 'ES')" separator="or"/>
            </field>
        </field>
    </record>

        <menuitem id="menu_l10n_es_edi_sii_root"
                  name="Spain SII"
                  sequence="110"
                  groups="account.group_account_manager"
                  parent="account.menu_finance_configuration">
            <menuitem id="menu_l10n_es_edi_sii_certificates"
                      name="Certificates"
                      action="l10n_es_edi_sii_certificate_action"
                      sequence="100"
                      groups="account.group_account_manager"/>
        </menuitem>
</odoo>
