<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="hr_timesheet_line_tree" model="ir.ui.view">
        <field name="name">Timesheet with lead/opportunity</field>
        <field name="model">account.analytic.line</field>
        <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
        <field name="arch" type="xml">
            <field name="task_id" position="after">
                <field name="lead_id" invisible="1" />
                <field
                    name="lead_id"
                    invisible="context.get('base_model_name') == 'crm.lead'"
                    groups="sales_team.group_sale_salesman"
                    optional="show"
                />
            </field>
        </field>
    </record>
    <record id="hr_timesheet_line_form" model="ir.ui.view">
        <field name="name">Lead/opportunity in timesheet line form</field>
        <field name="model">account.analytic.line</field>
        <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form" />
        <field name="arch" type="xml">
            <field name="task_id" position="after">
                <field name="lead_id" invisible="1" />
                <field name="lead_id" groups="sales_team.group_sale_salesman" />
            </field>
        </field>
    </record>
</odoo>
