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

    <record id="l10n_fr_pdp_view_out_invoice_tree" model="ir.ui.view">
        <field name="name">account.move.tree.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account_peppol.account_peppol_view_out_invoice_tree_inherit"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <field name="peppol_move_state" position="after">
                <field name="pdp_ppf_move_state"
                       widget="badge"
                       optional="hide"
                       decoration-danger="pdp_ppf_move_state == 'error'"
                       decoration-success="pdp_ppf_move_state == 'done'"
                       decoration-info="pdp_ppf_move_state in ('in_progress', 'sent')"
                       invisible="not pdp_ppf_move_state"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_view_out_credit_note_tree" model="ir.ui.view">
        <field name="name">account.move.refund.tree.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account_peppol.account_peppol_view_out_credit_note_tree_inherit"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <field name="peppol_move_state" position="after">
                <field name="pdp_ppf_move_state"
                       widget="badge"
                       optional="hide"
                       decoration-danger="pdp_ppf_move_state == 'error'"
                       decoration-success="pdp_ppf_move_state == 'done'"
                       decoration-info="pdp_ppf_move_state in ('in_progress', 'sent')"
                       invisible="not pdp_ppf_move_state"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_view_in_invoice_refund_tree_inherit" model="ir.ui.view">
        <field name="name">account.move.list.inherit</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_in_invoice_refund_tree" />
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="peppol_move_state" optional="hide"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_view_in_bill_tree_inherit" model="ir.ui.view">
        <field name="name">account.move.tree.inherit</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_in_invoice_bill_tree" />
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="peppol_move_state" optional="hide"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_view_move_form" model="ir.ui.view">
        <field name="name">l10n.fr.pdp.view.move.form</field>
        <field name="model">account.move</field>
        <field name="priority">30</field>
        <field name="inherit_id" ref="account_peppol.account_peppol_view_move_form"/>
        <field name="arch" type="xml">
            <!-- We do not show the "Reset to draft" but stil need to be able to cancel-->
            <button name="button_cancel" position="after">
                <button name="button_cancel" type="object" groups="account.group_account_invoice" data-hotkey="x"
                        string="Cancel" confirm="Do you really want to cancel this journal entry?"
                        invisible="state != 'posted' or show_reset_to_draft_button or not pdp_is_sent"
                        />
            </button>
            <label for="peppol_move_state" position="attributes">
                <attribute name="string">E-Invoicing Status</attribute>
            </label>
            <xpath expr="//div[@name='journal_div']" position="after">
                <label for="pdp_ppf_move_state" groups="base.group_no_one" invisible="not pdp_ppf_move_state"/>
                <div name="pdp_ppf_info" groups="base.group_no_one" invisible="not pdp_ppf_move_state">
                    <field name="pdp_ppf_move_state"/>
                </div>
            </xpath>
        </field>
    </record>

    <record id="l10n_fr_pdp_view_account_invoice_filter" model="ir.ui.view">
        <field name="name">account.invoice.select.inherit</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account_peppol.account_peppol_view_account_invoice_filter"/>
        <field name="arch" type="xml">
            <filter name="peppol_ready" position="attributes">
                <attribute name="string">E-Invoicing Ready</attribute>
            </filter>
            <filter name="peppol_move_state" position="attributes">
                <attribute name="string">E-Invoicing Status</attribute>
            </filter>
        </field>
    </record>

    <record id="l10n_fr_pdp_reports_view_out_invoice_tree" model="ir.ui.view">
        <field name="name">account.move.tree.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_out_invoice_tree"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="l10n_fr_pdp_status"
                        widget="badge"
                        optional="hide"
                        decoration-danger="l10n_fr_pdp_status == 'error'"
                        decoration-success="l10n_fr_pdp_status == 'sent'"
                        decoration-info="l10n_fr_pdp_status == 'ready'"
                        decoration-muted="l10n_fr_pdp_status in ('pending', 'out_of_scope')"
                        invisible="not l10n_fr_pdp_status"/>
            </field>
        </field>
    </record>
    <record id="l10n_fr_pdp_reports_view_out_credit_note_tree" model="ir.ui.view">
        <field name="name">account.move.refund.tree.l10n.fr.pdp.flow10.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_out_credit_note_tree"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="l10n_fr_pdp_status"
                        widget="badge"
                        optional="hide"
                        decoration-danger="l10n_fr_pdp_status == 'error'"
                        decoration-success="l10n_fr_pdp_status == 'sent'"
                        decoration-info="l10n_fr_pdp_status == 'ready'"
                        decoration-muted="l10n_fr_pdp_status in ('pending', 'out_of_scope')"
                        invisible="not l10n_fr_pdp_status"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_reports_view_move_form" model="ir.ui.view">
        <field name="name">account.move.form.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <button name="button_cancel" position="after">
                <button
                    name="button_cancel" string="Cancel" type="object"
                    groups="account.group_account_invoice" data-hotkey="x"
                    invisible="not id or state != 'posted' or not l10n_fr_pdp_sent_in_flow_ids"
                />
            </button>
        </field>
    </record>

    <record id="l10n_fr_pdp_reports_view_in_invoice_tree" model="ir.ui.view">
        <field name="name">account.move.in.invoice.tree.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_in_invoice_tree"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="l10n_fr_pdp_status"
                        widget="badge"
                        optional="hide"
                        decoration-danger="l10n_fr_pdp_status == 'error'"
                        decoration-success="l10n_fr_pdp_status == 'sent'"
                        decoration-info="l10n_fr_pdp_status == 'ready'"
                        decoration-muted="l10n_fr_pdp_status in ('pending', 'out_of_scope')"
                        invisible="not l10n_fr_pdp_status"/>
            </field>
        </field>
    </record>

    <record id="l10n_fr_pdp_reports_view_move_kanban" model="ir.ui.view">
        <field name="name">account.move.kanban.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_account_move_kanban"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='status_in_payment'][@widget='badge']" position="after">
                <field name="l10n_fr_pdp_status"
                        widget="badge"
                        decoration-danger="l10n_fr_pdp_status == 'error'"
                        decoration-success="l10n_fr_pdp_status == 'sent'"
                        decoration-info="l10n_fr_pdp_status == 'ready'"
                        decoration-muted="l10n_fr_pdp_status in ('pending', 'out_of_scope')"
                        invisible="not l10n_fr_pdp_status"/>
            </xpath>
        </field>
    </record>

    <record id="l10n_fr_pdp_reports_view_move_search" model="ir.ui.view">
        <field name="name">account.move.search.l10n.fr.pdp.status</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_account_invoice_filter"/>
        <!-- TODO master: remove this obsolete view. Kept inactive in stable for upgrade safety. -->
        <field name="active" eval="False"/>
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='posted']" position="after">
                <separator/>
                <filter name="l10n_fr_pdp_status_pending"
                        string="PDP Pending"
                        domain="[('l10n_fr_pdp_status', '=', 'pending')]"/>
                <filter name="l10n_fr_pdp_status_ready"
                        string="PDP Ready"
                        domain="[('l10n_fr_pdp_status', '=', 'ready')]"/>
                <filter name="l10n_fr_pdp_status_error"
                        string="PDP Error"
                        domain="[('l10n_fr_pdp_status', '=', 'error')]"/>
                <filter name="l10n_fr_pdp_status_sent"
                        string="PDP Sent"
                        domain="[('l10n_fr_pdp_status', '=', 'sent')]"/>
                <filter name="l10n_fr_pdp_status_out_of_scope"
                        string="PDP Out Of Scope"
                        domain="[('l10n_fr_pdp_status', '=', 'out_of_scope')]"/>
                <separator/>
                <filter name="l10n_fr_pdp_group_by_status"
                        string="Group By PDP Status"
                        context="{'group_by': 'l10n_fr_pdp_status'}"/>
                <filter name="l10n_fr_pdp_group_by_period"
                        string="Group By Invoice Month"
                        context="{'group_by': 'invoice_date:month'}"/>
                <filter name="l10n_fr_pdp_group_by_flow"
                        string="Group By Last PDP Flow"
                        context="{'group_by': 'l10n_fr_pdp_last_flow_id'}"/>
            </xpath>
        </field>
    </record>

    <record id="l10n_fr_pdp_action_open_response_wizard" model="ir.actions.server">
        <field name="name">Send Response</field>
        <field name="model_id" ref="account.model_account_move"/>
        <!-- TODO master: remove this obsolete action. Kept unbound in stable for upgrade safety. -->
        <field name="binding_model_id" eval="False"/>
        <field name="binding_view_types"></field>
        <field name="state">code</field>
        <field name="sequence">8</field>
        <field name="code">
            if records:
                action = records.action_pdp_open_response_wizard()
        </field>
    </record>

</odoo>
