<?xml version="1.0" encoding="utf-8"?>
<!--
  © 2014-2016 Akretion (http://www.akretion.com/)
  @author: Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->

<odoo>

<record id="view_partner_form" model="ir.ui.view">
    <field name="name">base_usability.title.on.partner.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <!-- Show title not only on Contacts -->
        <xpath expr="//field[@name='child_ids']/form//field[@name='title']" position="attributes">
            <attribute name="attrs"></attribute>
        </xpath>
        <!-- Show double VAT partner even when not in editable mode -->
        <div attrs="{'invisible': [('same_vat_partner_id', '=', False)]}" position="attributes">
            <attribute name="class">alert alert-warning</attribute>
        </div>
        <!-- Native order: city / state_id / zip. New order: zip / city / state_id -->
        <xpath expr="//div[hasclass('o_address_format')]/field[@name='city']" position="before">
            <field name="zip" position="move"/>
        </xpath>
        <field name="industry_id" position="attributes">
            <attribute name="attrs">{'invisible': [('parent_id', '!=', False)]}</attribute>
        </field>
    </field>
</record>

<record id="res_partner_view_form_private" model="ir.ui.view">
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.res_partner_view_form_private"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='bank_ids']/tree/field[@name='acc_holder_name']" position="attributes">
            <attribute name="invisible">0</attribute>
            <attribute name="optional">hide</attribute>
        </xpath>
    </field>
</record>

<record id="view_partner_simple_form" model="ir.ui.view">
    <field name="name">base_usability.title.on.partner.simplified.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_simple_form"/>
    <field name="arch" type="xml">
        <field name="function" position="before">
            <field name="title"/>
        </field>
    </field>
</record>

<record id="view_partner_tree" model="ir.ui.view">
    <field name="name">base_usability.res.partner.tree</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_tree"/>
    <field name="arch" type="xml">
        <field name="display_name" position="after">
            <field name="ref" optional="hide"/>
        </field>
        <field name="phone" position="after">
            <field name="mobile" optional="show" widget="phone" class="o_force_ltr"/>
        </field>
        <field name="category_id" position="after">
            <field name="industry_id" optional="hide"/>
        </field>
    </field>
</record>

<record id="view_res_partner_filter" model="ir.ui.view">
    <field name="name">base_usability.partner.search.form</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_res_partner_filter"/>
    <field name="arch" type="xml">
        <field name="name" position="attributes">
            <attribute name="string">Name or Email or Reference</attribute>
            <!-- for 'ref', change '=' to 'start with' -->
            <attribute name="filter_domain">['|','|',('display_name','ilike',self),('ref','=ilike',self + '%'),('email','ilike',self)]</attribute>
        </field>
        <filter name="group_country" position="after">
            <filter name="industry_groupby" string="Industry" context="{'group_by': 'industry_id'}"/>
        </filter>
    </field>
</record>

</odoo>
