<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.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">
            <!-- LEAD -->
            <xpath
                expr="//group[@name='lead_partner']/field[@name='website']"
                position="before"
            >
                <field name="partner_contact_assigned_id" />
                <field name="partner_assigned_id" />
            </xpath>
            <xpath
                expr="//group[@name='opportunity_partner']/label[@for='email_from']"
                position="before"
            >
                <field name="partner_contact_assigned_id" />
                <field name="partner_assigned_id" />
            </xpath>
        </field>
    </record>

    <record id="crm_case_tree_view_leads" model="ir.ui.view">
        <field name="name">crm.lead.tree.lead</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_tree_view_leads" />
        <field name="arch" type="xml">
            <xpath expr="//tree/field[@name='country_id']" position="after">
                <field name="partner_assigned_id" optional="hide" />
                <field name="partner_contact_assigned_id" optional="hide" />
            </xpath>
        </field>
    </record>

    <record id="crm_case_tree_view_oppor" model="ir.ui.view">
        <field name="name">crm.lead.tree.opportunity</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_tree_view_oppor" />
        <field name="arch" type="xml">
            <xpath expr="//tree/field[@name='country_id']" position="after">
                <field name="partner_assigned_id" optional="hide" />
                <field name="partner_contact_assigned_id" optional="hide" />
            </xpath>
        </field>
    </record>

    <record id="view_crm_case_leads_filter" model="ir.ui.view">
        <field name="name">crm.lead.search.lead</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.view_crm_case_leads_filter" />
        <field name="arch" type="xml">
            <xpath expr="//search/field[@name='activity_state']" position="before">
                <field name="partner_assigned_id" />
            </xpath>
            <xpath expr="//search/group/separator" position="before">
                <filter
                    string="Assigned partner"
                    name="grp_partner_assigned"
                    context="{'group_by': 'partner_assigned_id'}"
                />
            </xpath>
        </field>
    </record>

    <record id="view_crm_case_opportunities_filter" model="ir.ui.view">
        <field name="name">crm.lead.search.opportunity</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.view_crm_case_opportunities_filter" />
        <field name="arch" type="xml">
            <xpath expr="//search/field[@name='activity_state']" position="before">
                <field name="partner_assigned_id" />
            </xpath>
            <xpath expr="//search/group/separator" position="before">
                <filter
                    string="Assigned partner"
                    name="grp_partner_assigned"
                    context="{'group_by': 'partner_assigned_id'}"
                />
            </xpath>
        </field>
    </record>
</odoo>
