<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="invoice_form_inherit_l10n_in_edi" model="ir.ui.view">
        <field name="name">account.move.form.inherit.l10n.in.edi</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <!-- E-Invoice -->
            <xpath expr="//group[@name='sale_info_group']" position="inside">
                <field name="l10n_in_edi_cancel_reason"
                       string="EDI Cancel Reason"
                       invisible="not l10n_in_edi_cancel_reason"
                       readonly="1"/>
                <field name="l10n_in_edi_cancel_remarks"
                       string="EDI Cancel Remarks"
                       invisible="not l10n_in_edi_cancel_remarks"
                       readonly="1"/>
            </xpath>
            <xpath expr="//header" position="after">
                <div class="alert alert-danger" role="alert"
                     invisible="not l10n_in_edi_error">
                    <div class="o_row">
                        <field name="l10n_in_edi_error"/>
                        <button name="action_l10n_in_edi_force_cancel"
                                type="object"
                                class="oe_link oe_inline"
                                confirm="Are you sure you want to cancel this invoice without waiting for the EDI document to be canceled?"
                                invisible="l10n_in_edi_status != 'sent'"
                                string="Force Cancel"/>
                    </div>
                </div>
            </xpath>
            <xpath expr="//button[@name='button_draft']" position="after">
                <button name="action_export_l10n_in_edi_content_json"
                        type="object"
                        class="btn-secondary"
                        invisible="not l10n_in_edi_error"
                        groups="base.group_no_one"
                        string="Download EDI JSON"/>
            </xpath>
            <xpath expr="//div[@name='journal_div']" position="after">
                <field name="l10n_in_edi_status" invisible="not l10n_in_edi_status or state == 'draft'"/>
            </xpath>
        </field>
    </record>
    <record id="view_out_invoice_tree_inherit_l10n_in_edi" model="ir.ui.view">
        <field name="name">out.invoice.list.inherit.l10n_in_edi</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_out_invoice_tree"/>
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="l10n_in_edi_status"
                       optional="hide"
                       widget="badge"
                       decoration-success="l10n_in_edi_status == 'sent'"
                       decoration-info="l10n_in_edi_status == 'to_send'"
                       decoration-danger="l10n_in_edi_status == 'cancelled'"/>
            </field>
        </field>
    </record>
    <record id="view_out_credit_note_tree_inherit_l10n_in_edi" model="ir.ui.view">
        <field name="name">out.credit.note.list.inherit.l10n_in_edi</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_out_credit_note_tree"/>
        <field name="arch" type="xml">
            <field name="status_in_payment" position="before">
                <field name="l10n_in_edi_status"
                       optional="hide"
                       widget="badge"
                       decoration-success="l10n_in_edi_status == 'sent'"
                       decoration-info="l10n_in_edi_status == 'to_send'"
                       decoration-danger="l10n_in_edi_status == 'cancelled'"/>
            </field>
        </field>
    </record>
    <record id="l10n_in_edi_inherit_account_move_search_view" model="ir.ui.view">
        <field name="name">l10n.in.edi.inherit.account.move.search</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_account_invoice_filter" />
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='cancel']" position="after">
                <separator/>
                <filter name="l10n_in_edi_to_send" string="Indian E-Invoices To Send" domain="[('l10n_in_edi_status', '=', 'to_send')]"/>
                <filter name="l10n_in_edi_error_move" string="Indian E-Invoices In Error" domain="[('l10n_in_edi_error', '!=', False)]"/>
            </xpath>
            <xpath expr="//filter[@name='status']" position="after">
                <filter name="groupby_l10n_in_edi_status" string="Indian E-invoice status" context="{'group_by' : 'l10n_in_edi_status'}"/>
            </xpath>
        </field>
    </record>
</odoo>
