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

    <!-- ================================================================== -->
    <!-- Tax Form Extension - Python Compute Fields                          -->
    <!-- ================================================================== -->
    <record id="view_tax_form_python_compute" model="ir.ui.view">
        <field name="name">account.tax.form.python.compute</field>
        <field name="model">account.tax</field>
        <field name="inherit_id" ref="account.view_tax_form"/>
        <field name="arch" type="xml">
            <!-- Show python_compute field when amount_type is 'python' -->
            <xpath expr="//field[@name='amount']" position="after">
                <field name="python_compute"
                       widget="code"
                       invisible="amount_type != 'python'"
                       options="{'mode': 'python'}"
                       placeholder="# Assign the computed tax amount to 'result'&#10;result = price_unit * quantity * 0.10"/>
                <field name="python_applicable"
                       widget="code"
                       invisible="amount_type != 'python'"
                       options="{'mode': 'python'}"
                       placeholder="# Optional: assign True/False to 'result' to control applicability&#10;result = True"/>
            </xpath>
        </field>
    </record>

    <!-- ================================================================== -->
    <!-- Tax List Extension - Show Python badge                              -->
    <!-- ================================================================== -->
    <record id="view_tax_list_python" model="ir.ui.view">
        <field name="name">account.tax.list.python</field>
        <field name="model">account.tax</field>
        <field name="inherit_id" ref="account.view_tax_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='amount_type']" position="attributes">
                <attribute name="decoration-info">amount_type == 'python'</attribute>
            </xpath>
        </field>
    </record>

</odoo>
