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

    <record id="crm_lead_form_cor_custom" model="ir.ui.view">
        <field name="name">crm.lead.cor.inherit1</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="replace">
                <field name="partner_id"
                       widget="res_partner_many2one"
                       string="Client"
                       context="{'res_partner_search_mode': type == 'opportunity' and 'customer' or False,
                                        'default_name': contact_name or partner_name,
                                        'default_street': street,
                                        'default_is_company': type == 'opportunity' and contact_name == False,
                                        'default_company_name': type == 'opportunity' and partner_name,
                                        'default_street2': street2,
                                        'default_city': city,
                                        'default_title': title,
                                        'default_state_id': state_id,
                                        'default_zip': zip,
                                        'default_country_id': country_id,
                                        'default_function': function,
                                        'default_phone': phone,
                                        'default_mobile': mobile,
                                        'default_email': email_from,
                                        'default_user_id': user_id,
                                        'default_team_id': team_id,
                                        'default_website': website,
                                        'show_vat': True,
                                    }"
                />
            </xpath>
            <!--<xpath expr="//field[@name='user_id']" position="replace">
            <field name="set_readonly" invisible="1" />
            <field name="user_id" domain="[('share', '=', False)]" attrs="{'readonly': [('set_readonly','!=',True)]}"
                                    context="{'default_sales_team_id': team_id}" widget="many2one_avatar_user"/>
            </xpath>-->
            <xpath expr="//group[@name='Misc']" position="after">
                <group colspan="2" col="4">
                    <field name="lead_no"/>
                    <field name="scope"/>
                    <field name="professional_support"/>
                    <field name="ref_summary_status"/>
                    <field name="contract"/>
                    <field name="client_folder"/>
                    <field name="start_date"/>
                    <field name="close_date"/>
                    <field name="project_name"/>
                    <field name="project_scope"/>
                    <field name="act_project_manager_id"/>
                    <field name="project_manager_id"/>
                </group>
            </xpath>
            <xpath expr="//field[@name='user_id']" position="replace">
                <field name="admin_user" invisible="1"/>
                <field name="user_id" domain="[('share', '=', False)]" attrs="{'readonly':[('admin_user','=',False)]}"
                       context="{'default_sales_team_id': team_id}" widget="many2one_avatar_user"/>

            </xpath>
        </field>
    </record>


    <!-- <record id="view_salesperson_readonly_custom" model="ir.ui.view">
          <field name="name">crm.lead.cor.inherit2</field>
          <field name="model">crm.lead</field>
          <field name="inherit_id" ref="cor_custom.crm_lead_form_cor_custom"/>
          <field name="groups_id" eval="[(6, 0, [ref('base.group_erp_manager')])]"/>
          <field name="arch" type="xml">
              <xpath expr="//field[@name='user_id']" position="attributes">
                  <attribute name="readonly">False</attribute>
              </xpath>
          </field>
      </record>
  -->
    <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="arch" type="xml">
            <xpath expr="//kanban" position="attributes">
                <attribute name="on_create"/>
            </xpath>
        </field>
    </record>
</odoo>
