<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="res_config_settings_view_form" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.inherit.proxy.user</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="account.res_config_settings_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//block[@id='peppol']" position="after">
                <block title="Nemhandel E-Delivery" id="nemhandel" invisible="country_code != 'DK'">
                    <div id="l10n_dk_nemhandel" class="col-12 o_setting_box">
                        <div class="o_setting_right_pane border-0">

                            <div invisible="l10n_dk_nemhandel_proxy_state != 'receiver'">
                                You are sending and receiving your e-invoices via Odoo with this Nemhandel ID <field name="nemhandel_edi_identification" class="oe_inline o_form_label" readonly="1"/>.
                            </div>
                            <div invisible="l10n_dk_nemhandel_proxy_state != 'receiver'" class="mt-4">
                                <div class="row" name="nemhandel_journal_config">
                                    <label string="Incoming Invoices Journal"
                                           for="nemhandel_purchase_journal_id"
                                           class="col-lg-3"/>
                                    <field name="nemhandel_purchase_journal_id"
                                           required="l10n_dk_nemhandel_proxy_state == 'receiver'"/>
                                </div>
                                <div class="row" name="nemhandel_contact_email">
                                    <label string="Contact Email"
                                           for="nemhandel_contact_email"
                                           class="col-lg-3"/>
                                    <field name="nemhandel_contact_email"
                                           required="l10n_dk_nemhandel_proxy_state == 'receiver'"/>
                                </div>
                            </div>

                            <!-- Info in case of rejected. -->
                            <div invisible="l10n_dk_nemhandel_proxy_state != 'rejected'">
                                You registration has been rejected, the reason has been sent to you via email.
                                Please contact our support if you need further assistance.
                            </div>

                            <div class="d-flex gap-1 action_buttons mt-2"
                                 invisible="l10n_dk_nemhandel_proxy_state != 'receiver'">
                                <button name="button_update_nemhandel_user_data"
                                        type="object"
                                        class="btn btn-primary me-1"
                                        string="Update contact details"/>
                                <button name="button_deregister_nemhandel_participant"
                                        type="object"
                                        string="Deregister"
                                        confirm="This will delete your Nemhandel registration."
                                        class="btn btn-secondary me-1"/>
                            </div>

                            <div class="d-flex gap-1 action_buttons" colspan="3">
                                <!-- Not yet registered on Nemhandel -->
                                <div invisible="l10n_dk_nemhandel_proxy_state not in ('not_registered', 'in_verification')">
                                    <div class="text-muted">
                                        Allow sending and receiving invoices through the Nemhandel network
                                    </div>
                                    <button name="action_open_nemhandel_form"
                                            type="object"
                                            string="Start sending via Nemhandel"
                                            class="oe_highlight mt-2"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </block>
            </xpath>
        </field>
    </record>
</odoo>
