<?xml version="1.0" encoding="utf-8" ?>
<!--
    Copyright 2017-2022 Akretion France (http://www.akretion.com/)
    @author: Alexis de Lattre <alexis.delattre@akretion.com>
    Copyright 2021-2022 Camptocamp SA (https://www.camptocamp.com).
    @author: Iván Todorovich <ivan.todorovich@camptocamp.com>
    License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
    <record id="view_move_form" model="ir.ui.view">
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form" />
        <field name="arch" type="xml">
            <!--
                For customer invoices, the field transmit_method_id is displayed
                at the top. For vendor bills, it is displayed in the 3rd tab.
            -->
            <div name="journal_div" position="after">
                <field
                    name="transmit_method_id"
                    widget="selection"
                    invisible="move_type not in ('out_invoice', 'out_refund')"
                />
            </div>
            <field name="invoice_source_email" position="after">
                <field
                    name="transmit_method_id"
                    widget="selection"
                    invisible="move_type not in ('in_invoice', 'in_refund')"
                />
            </field>
            <!--
            button name="action_invoice_sent" string="Send and Print"
            is used twice in the view:
            one with class="oe_highlight" and a second one without highlight
            The buttons should only be shown when the transmit method is
            E-mail or empty
            -->
            <xpath
                expr="//button[@name='action_invoice_sent' and hasclass('oe_highlight')]"
                position="attributes"
            >
                <attribute
                    name="invisible"
                >state != 'posted' or is_being_sent or invoice_pdf_report_id or move_type not in ('out_invoice', 'out_refund') or transmit_method_code not in ('mail', False)</attribute>
            </xpath>
            <xpath
                expr="//button[@name='action_invoice_sent' and not(hasclass('oe_highlight'))]"
                position="attributes"
            >
                <attribute
                    name="invisible"
                >state != 'posted' or not is_being_sent and not invoice_pdf_report_id or move_type not in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund') or transmit_method_code not in ('mail', False)</attribute>
            </xpath>
        </field>
    </record>
</odoo>
