<?xml version="1.0" ?>
<odoo>

    <record id="crm_lead_view_form" model="ir.ui.view">
        <field name="name">crm.lead.form</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_lead_view_form" />
        <field name="arch" type="xml">
            <xpath
                expr="//group[@name='opportunity_partner']//field[@name='partner_id']"
                position="before"
            >
                <field name="customer_currency_id" />
                <field name="is_same_currency" invisible="1" />
                <field
                    name="amount_customer_currency"
                    attrs="{'invisible': [('is_same_currency', '=', True)]}"
                />
            </xpath>
            <field name="expected_revenue" position="attributes">
                <attribute name="attrs">
                    {'readonly': [('is_same_currency', '=', False)]}
                </attribute>
                <attribute name="force_save">1</attribute>
            </field>
        </field>
    </record>

    <!-- In kanban display the amount in the customer currency as suitable -->
    <record id="crm_case_kanban_view_leads" model="ir.ui.view">
        <field name="name">crm.lead.kanban.lead</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_kanban_view_leads" />
        <field name="priority">99</field>
        <field name="arch" type="xml">
            <field name="expected_revenue" position="after">
                <field name="is_same_currency" />
                <field name="amount_customer_currency" />
                <field name="customer_currency_id" />
            </field>
            <xpath
                expr="//templates//field[@name='expected_revenue']"
                position="replace"
            >
                <t t-if="record.is_same_currency.raw_value">
                    <field
                        name="expected_revenue"
                        widget="monetary"
                        options="{'currency_field': 'company_currency'}"
                    />
                </t>
                <t t-else="">
                    <field
                        name="amount_customer_currency"
                        widget="monetary"
                        options="{'currency_field': 'customer_currency_id'}"
                    />
                </t>
            </xpath>
        </field>
    </record>

</odoo>
