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

    <record id="survey_survey_view_form" model="ir.ui.view">
        <field name="name">survey.survey.view.form.inherit.survey.crm</field>
        <field name="model">survey.survey</field>
        <field name="inherit_id" ref="survey.survey_survey_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_survey_user_input_completed']" position="after">
                <button name="action_survey_see_leads"
                    groups="sales_team.group_sale_salesman"
                    type="object"
                    class="oe_stat_button"
                    invisible="not (survey_type in ['survey', 'live_session', 'custom'] and lead_count != 0)"
                    icon="fa-star">
                    <field string="Leads" name="lead_count" widget="statinfo"/>
                </button>
            </xpath>

            <xpath expr="//field[@name='restrict_user_ids']" position="after">
                <field name="team_id" placeholder="Select a Sales team" invisible="not generate_lead"/>
            </xpath>

            <xpath expr="//list//field[@name='title']" position="after">
                <button type="button" icon="fa-star" title="This question generates leads"
                        invisible="not (survey_type in ['survey', 'live_session', 'custom'] and generate_lead)"/>
            </xpath>
        </field>
    </record>

    <record id="survey_survey_view_kanban" model="ir.ui.view">
        <field name="name">survey.survey.view.kanban.inherit.survey.crm</field>
        <field name="model">survey.survey</field>
        <field name="inherit_id" ref="survey.survey_survey_view_kanban"/>
        <field name="arch" type="xml">
            <xpath expr="//div[a[@name='action_survey_user_input_completed']]" position="after">
                <div t-if="!selection_mode and record.lead_count.raw_value > 0" class="col-lg-1 col-sm-4 col-6 py-0 my-2">
                    <a type="object" name="action_survey_see_leads" class="fw-bold">
                        <field name="lead_count"/><br/>
                        <span class="text-muted">Leads</span>
                    </a>
                </div>
            </xpath>
        </field>
    </record>

</data>
</odoo>
