<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_move_form_inherit_repair_vendor_refund" model="ir.ui.view">
        <field name="name">account.move.inherit.repair.vendor.refund</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form" />
        <field name="arch" type="xml">
            <field name="invoice_vendor_bill_id" position="after">
                <label
                    for="purchase_return_id"
                    string="Auto-Complete Return Order"
                    class="oe_edit_only"
                    attrs="{'invisible': ['|', ('state','!=','draft'), ('move_type', '!=', 'in_refund')]}"
                />
                <field
                    name="purchase_return_id"
                    nolabel="1"
                    attrs="{'invisible': ['|', ('state','!=','draft'), ('move_type', '!=', 'in_refund')]}"
                    class="oe_edit_only"
                    domain="[('company_id', '=', company_id), ('partner_id','child_of', [partner_id])]"
                    placeholder="Select a purchase return order"
                    options="{'no_create': True, 'no_open': True}"
                />
            </field>
            <!-- Add link to purchase_line_id to account.move.line -->
            <xpath
                expr="//field[@name='invoice_line_ids']/tree/field[@name='company_id']"
                position="after"
            >
                <field name="purchase_return_line_id" invisible="1" />
                <field
                    name="purchase_return_order_id"
                    attrs="{'column_invisible': [('parent.move_type', '!=', 'in_invoice')]}"
                    optional="hide"
                />
            </xpath>
            <xpath
                expr="//field[@name='line_ids']/tree/field[@name='company_id']"
                position="after"
            >
                <field name="purchase_return_line_id" invisible="1" />
            </xpath>
        </field>
    </record>
</odoo>
