<odoo>
    <record id="view_project_project_budget_tree" model="ir.ui.view">
        <field name="model">project.project.budget</field>
        <field name="arch" type="xml">
            <tree editable="bottom">
                <field name="project_id" />
                <field name="sale_order_id_domain" invisible="1" />
                <field
                    name="sale_order_id"
                    required="1"
                    attrs="{'column_invisible': [('parent.sale_order_id', '!=', False)]}"
                    domain="sale_order_id_domain"
                />
                <field name="date" optional="show" />
                <field name="name" optional="show" />
                <field name="quantity" optional="show" />
                <field name="price_unit" />
                <field name="amount" sum="Amount" optional="show" />
            </tree>
        </field>
    </record>
    <record id="view_project_project_budget_tree_custom" model="ir.ui.view">
        <field name="model">project.project.budget</field>
        <field name="inherit_id" ref="view_project_project_budget_tree" />
        <field name="mode">primary</field>
        <field name="priority">1000</field>
        <field name="arch" type="xml">
            <field name="project_id" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
        </field>
    </record>
    <record id="project_project_view_form" model="ir.ui.view">
        <field name="name">project.project.form.inherit - Add budget</field>
        <field name="model">project.project</field>
        <field name="inherit_id" ref="sale_timesheet.project_project_view_form" />
        <field name="arch" type="xml">
            <page name="settings" position="after">
                <page name="budgets" string="Budgets">
                    <field
                        name="budget_ids"
                        context="{'default_sale_order_id': sale_order_id, 'tree_view_ref': 'sale_timesheet_budget.view_project_project_budget_tree_custom', 'default_project_id': id}"
                    />
                </page>
            </page>
        </field>
    </record>
    <record id="action_project_project_budget" model="ir.actions.act_window">
        <field name="name">Project Budgets</field>
        <field name="res_model">project.project.budget</field>
        <field name="view_mode">tree</field>
    </record>
</odoo>
