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

<record id="view_res_partner_filter_contact" model="ir.ui.view">
    <field name="name">res.partner.select.contact</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_res_partner_filter"/>
    <field name="arch" type="xml">
        <filter name="type_company" position="after">
            <separator/>
            <filter string="All positions" name="type_otherpositions"
                    context="{'search_show_all_positions': {'is_set': True, 'set_value': True}}"
                    help="All partner positions"/>
        </filter>
        <xpath expr="/search/group[@name='group_by']" position="inside">
            <filter string="Person" name="group_person" context="{'group_by': 'contact_id'}"/>
        </xpath>
    </field>
</record>

<record id="view_res_partner_tree_contact" model="ir.ui.view">
    <field name="name">res.partner.tree.contact</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_tree"/>
    <field name="arch" type="xml">
        <field name="parent_id" position="after">
            <field name="contact_id" invisible="1"/>
        </field>
    </field>
</record>

<record model="ir.ui.view" id="view_partner_form_inherit">
    <field name="name">res.partner.form.contact</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <field name="is_company" position="after">
            <field name="contact_type" invisible="1"/>
        </field>
        <page name='internal_notes' position="before">
            <page string="Other Positions" attrs="{'invisible': ['|',('is_company','=',True),('contact_id','!=',False)]}">
                <field name="other_contact_ids" context="{'default_contact_id': active_id, 'default_name': name, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier}}" mode="kanban">
                    <kanban>
                        <field name="color"/>
                        <field name="name"/>
                        <field name="title"/>
                        <field name="email"/>
                        <field name="parent_id"/>
                        <field name="is_company"/>
                        <field name="function"/>
                        <field name="phone"/>
                        <field name="street"/>
                        <field name="street2"/>
                        <field name="zip"/>
                        <field name="city"/>
                        <field name="country_id"/>
                        <field name="mobile"/>
                        <field name="fax"/>
                        <field name="state_id"/>
                        <field name="image"/>
                        <field name="lang"/>
                        <templates>
                            <t t-name="kanban-box">
                                <t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
                                <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '') + ' oe_kanban_global_click'">
                                    <a t-if="!read_only_mode" type="delete" class="fa fa-times pull-right"/>
                                    <div class="o_kanban_image">
                                        <img t-if="record.image.raw_value" t-att-src="'data:image/png;base64,'+record.image.raw_value"/>
                                        <t t-if="!record.image.raw_value">
                                            <img t-if="record.is_company.raw_value === true" t-att-src='_s + "/base/static/src/img/company_image.png"'/>
                                            <img t-if="record.is_company.raw_value === false" t-att-src='_s + "/base/static/src/img/avatar.png"'/>
                                        </t>
                                    </div>
                                    <div class="oe_kanban_details">
                                        <field name="name"/>
                                        <div t-if="record.function.raw_value"><field name="function"/></div>
                                        <div t-if="record.email.raw_value"><field name="email"/></div>
                                        <div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
                                        <div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
                                        <div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
                                    </div>
                                </div>
                            </t>
                        </templates>
                    </kanban>
                    <form string="Contact">
                        <sheet>
                            <field name="type" required="1" widget="radio" options="{'horizontal': true}"/>
                            <hr/>
                            <group>
                                <group attrs="{'invisible': [('type','=', 'contact')]}">
                                    <label for="street" string="Address"/>
                                    <div>
                                        <div class="o_address_format" name="div_address">
                                            <field name="street" placeholder="Street..." class="o_address_street"/>
                                            <field name="street2" placeholder="Street 2..." class="o_address_street"/>
                                            <field name="city" placeholder="City" class="o_address_city"/>
                                            <field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}' on_change="onchange_state(state_id)" context="{'country_id': country_id, 'zip': zip}"/>
                                            <field name="zip" placeholder="ZIP" class="o_address_zip"/>
                                            <field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
                                        </div>
                                    </div>
                                </group>
                                <group>
                                    <field name="name" string="Contact Name" attrs="{'required' : [('type', '=', 'contact')]}"/>
                                    <field name="title" placeholder="e.g. Mr."
                                        attrs="{'invisible': [('type','&lt;&gt;', 'contact')]}"/>
                                    <field name="function" placeholder="e.g. Sales Director"
                                        attrs="{'invisible': [('type','&lt;&gt;', 'contact')]}"/>
                                    <field name="email"/>
                                    <field name="phone" widget="phone"/>
                                    <field name="mobile" widget="phone"/>
                                    <field name="comment" placeholder="internal note..."/>
                                </group>
                            </group>
                            <field name="supplier" invisible="True"/>
                            <field name="customer" invisible="True"/>
                            <field name="lang" invisible="True"/>
                        </sheet>
                    </form>
                </field>
            </page>
        </page>
        <xpath expr="//field[@name='category_id']" position="before">
            <group>
                <label for="contact_type" class="oe_edit_only"/>
                <field name="contact_type" readonly="0" nolabel="1"/>
            </group>
        </xpath>
        <xpath expr="//field[@name='child_ids']/form//field[@name='name']" position="before">
            <field name='contact_type' readonly='0'/>
            <field name="contact_id" string="Contact"
                   attrs="{'invisible': [('contact_type','!=','attached')], 'required': [('contact_type','=','attached')]}"/>
        </xpath>
        <xpath expr="//field[@name='child_ids']/form//field[@name='name']" position="attributes">
            <attribute name="attrs">{'invisible': [('contact_type','=','attached')]}</attribute>
        </xpath>
    </field>
</record>

<record id="personal_contact_information" model="ir.ui.view">
    <field name="name">Contacts in several partners: personal info</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="partner_contact_personal_information_page.personal_information"/>
    <field name="arch" type="xml">
        <data>
            <xpath expr="//page[@name='personal_information_page']/group[@name='personal_information_group']"
                    position='attributes'>
                <attribute name='attrs'>{'invisible': [('contact_id','!=',False)]}</attribute>
            </xpath>
            <xpath expr="//page[@name='personal_information_page']/group[@name='personal_information_group']"
                    position='after'>
                <p attrs="{'invisible': [('contact_id','=',False)]}">
                    To see personal information about this contact, please
                    go to to the this person form:
                    <field name="contact_id" class="oe_inline"
                           domain="[('contact_type','!=','attached')]"
                           context="{'show_address': 1}"
                           options="{'always_reload': True}"/>
                </p>
            </xpath>
        </data>
  </field>
</record>

<record model="ir.ui.view" id="view_res_partner_kanban_contact">
    <field name="name">res.partner.kanban.contact</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.res_partner_kanban_view"/>
    <field name="arch" type="xml">
        <field name="is_company" position="after">
            <field name="other_contact_ids">
                <tree>
                    <field name="parent_id"/>
                    <field name="function"/>
                </tree>
            </field>
        </field>
        <xpath expr="//t[@t-name='kanban-box']//div[@class='oe_kanban_details']/ul/li[3]" position="after">
            <t t-if="record.other_contact_ids.raw_value.length &gt; 0">
                <li>+<t t-esc="record.other_contact_ids.raw_value.length"/>
                     <t t-if="record.other_contact_ids.raw_value.length == 1">other position</t>
                     <t t-if="record.other_contact_ids.raw_value.length &gt; 1">other positions</t></li>
            </t>
        </xpath>
    </field>
</record>

</data>
</odoo>