<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Form view extension: Add field and button in Purchases tab -->
    <record id="view_res_partner_form_price_category" model="ir.ui.view">
        <field name="name">res.partner.form.price.category</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <!-- Add in Sales & Purchase tab, inside page -->
            <xpath expr="//page[@name='sales_purchases']" position="inside">
                <group string="Price Category Settings">
                    <field name="default_price_category_id" />
                    <button
                        name="action_update_products_price_category"
                        type="object"
                        string="Apply to All Products"
                        class="btn-primary"
                        help="Update all products from this supplier with the selected price category"
                        invisible="not default_price_category_id"
                    />
                </group>
            </xpath>
        </field>
    </record>

    <!-- Tree view extension: Add hidden column for price category -->
    <record id="view_res_partner_tree_price_category" model="ir.ui.view">
        <field name="name">res.partner.tree.price.category</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_tree" />
        <field name="arch" type="xml">
            <field name="complete_name" position="after">
                <field name="default_price_category_id" column_invisible="1" />
            </field>
        </field>
    </record>
</odoo>
