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

    <record id="view_move_form_inherit_ocr" model="ir.ui.view">
        <field name="name">invoice.move.form.inherit.ocr</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <xpath expr="//header" position="inside">
                <button name="action_manual_send_for_digitization" class="oe_highlight" string="Digitize document" type="object"
                    invisible="not extract_can_show_send_button" data-hotkey="w" />
                <button name="action_reload_ai_data" string="Reload AI Data" type="object"
                    invisible="move_type not in ('in_invoice', 'in_refund', 'out_invoice', 'out_refund') or state != 'draft' or extract_state not in ['waiting_validation', 'validation_to_send']" />
            </xpath>
            <xpath expr="//sheet" position='before'>
                <field name="extract_error_message" invisible="1"/>
                <field name="extract_document_uuid" invisible="1"/>
                <field name="extract_state" class="d-block" invisible="not extract_can_show_banners or extract_state == 'waiting_validation'" widget="extract_state_header"/>
                <field name="extract_attachment_id" invisible="True"/>
                <field name="extract_can_show_send_button" invisible="True"/>
                <field name="extract_can_show_banners" invisible="True"/>
            </xpath>
            <xpath expr="//chatter" position="attributes">
                <attribute name="reload_on_post">True</attribute>
                <attribute name="reload_on_attachment">True</attribute>
            </xpath>
            <xpath expr="//page[@id='other_tab']//group[@name='accounting_info_group']" position="after">
                <group string="Extraction Information"
                       name="extraction_info_group"
                       invisible="move_type not in ('in_invoice', 'in_refund', 'out_invoice', 'out_refund') or extract_state in ('no_extract_requested', 'not_enough_credit')"
                       groups="base.group_no_one">
                    <field name="extract_document_uuid" widget="CopyClipboardChar"/>
                </group>
            </xpath>
        </field>
    </record>

    <record id="model_account_send_for_digitalization" model="ir.actions.server">
        <field name="name">Send Bills for digitization</field>
        <field name="model_id" ref="account.model_account_move"/>
        <field name="binding_model_id" ref="account.model_account_move"/>
        <field name="binding_view_types">list</field>
        <field name="state">code</field>
        <field name="code">
            if records:
                action = records.action_send_batch_for_digitization()
        </field>
    </record>

</odoo>
