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

    <record id="product_product_view_form_inherit_sale_expense" model="ir.ui.view">
        <field name="name">product.template.expense</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="hr_expense.product_product_expense_form_view"/>
        <field name="arch" type="xml">
            <xpath expr="//group[@name='product_details']" position="inside">
                <group string="Invoicing">
                    <field name="expense_policy" widget="radio"/>
                    <label for="expense_policy_tooltip" string=""/>
                    <div class="o_row">
                        <field name="expense_policy_tooltip" class="fst-italic text-muted"/>
                    </div>
                </group>
            </xpath>
            <xpath expr="//field[@name='standard_price']" position="before">
                <field name="list_price" attrs="{'invisible':[('expense_policy', '!=', 'sales_price')]}"/>
            </xpath>
            <xpath expr="//field[@name='supplier_taxes_id']" position="after">
                <field name="taxes_id" widget="many2many_tags" attrs="{'invisible':[('expense_policy', '=', 'no')]}"
                       options="{'no_quick_create': True}"/>
            </xpath>
        </field>
    </record>

    <record id="product_product_view_list_inherit_sale_expense" model="ir.ui.view">
        <field name="name">product.product.view.list.inherit.sale.expense</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="hr_expense.product_product_expense_categories_tree_view"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='supplier_taxes_id']" position="after">
                <field name="expense_policy" optional="show"/>
                <field name="taxes_id" optional="hide"/>
            </xpath>
        </field>
    </record>

    <record id="hr_expense.hr_expense_product" model="ir.actions.act_window">
        <field name="context">{"default_can_be_expensed": 1, 'default_detailed_type': 'service',
            'default_expense_policy' : 'cost'}</field>
    </record>

</odoo>
