<?xml version="1.0"?>
<form string="Partners">
                <div class="alert alert-warning oe_edit_only" role="alert" name="warning_tax" invisible="not same_vat_partner_id and not same_company_registry_partner_id">
                    Potential duplicates:
                    <span invisible="not same_vat_partner_id or same_company_registry_partner_id">
                        <field name="same_vat_partner_id" context="{'show_address': False, 'show_vat': False}"/>
                        (Same <field name="vat_label"/>)
                    </span>
                    <span invisible="same_vat_partner_id or not same_company_registry_partner_id">
                        <field name="same_company_registry_partner_id" context="{'show_address': False, 'show_vat': False}"/>
                        (Same <field name="company_registry_label"/>)
                    </span>
                    <span invisible="not (same_vat_partner_id and same_company_registry_partner_id and same_vat_partner_id == same_company_registry_partner_id)">
                        <field name="same_vat_partner_id" context="{'show_address': False, 'show_vat': False}"/>
                        (Same <field name="vat_label"/> and <field name="company_registry_label"/>)
                    </span>
                    <span invisible="not (same_vat_partner_id and same_company_registry_partner_id and same_vat_partner_id != same_company_registry_partner_id)">
                        <field name="same_vat_partner_id" context="{'show_address': False, 'show_vat': False}"/>
                        (Same <field name="vat_label"/>) and
                        <field name="same_company_registry_partner_id" context="{'show_address': False, 'show_vat': False}"/>
                        (Same <field name="company_registry_label"/>)
                    </span>
                </div>
                <sheet>
                    <div class="oe_button_box" name="button_box"/>
                    <widget name="web_ribbon" title="Archived" bg_color="text-bg-danger" invisible="active"/>
                    <div class="mb8">
                        <div class="d-flex gap-3">
                            <field name="image_1920" widget="contact_image" options="{'preview_image': 'avatar_128', 'size': [130,130], 'img_class': 'rounded border'}"/>
                            <field name="avatar_128" invisible="1"/> <!-- Needed in contact_image widget -->
                            <div class="d-flex flex-column flex-grow-1">
                                <field name="company_type" widget="radio" options="{'horizontal': true}"/>
                                <h1 class="mb-0 w-75">
                                    <field options="{'line_breaks': False}" widget="text" class="text-break d-block" name="name" default_focus="1" placeholder="e.g. Lumber Inc" invisible="not is_company" required="type == 'contact'"/>
                                    <field options="{'line_breaks': False}" widget="text" class="text-break d-block" name="name" default_focus="1" placeholder="e.g. Brandon Freeman" invisible="is_company" required="type == 'contact'"/>
                                </h1>
                                <div class="d-flex align-items-baseline w-50">
                                    <i class="fa fa-fw me-1 fa-envelope text-primary" title="Email"/>
                                    <field name="email" class="w-100" widget="email" required="user_ids" placeholder="Email"/>
                                </div>
                                <div class="d-flex align-items-baseline w-50">
                                    <i class="fa fa-fw me-1 fa-phone text-primary" title="Phone"/>
                                    <field name="phone" class="w-100" widget="phone" placeholder="Phone"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <group>
                        <group>
                            <field name="parent_id" widget="res_partner_many2one" placeholder="Company Name..." string="Company" domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'default_user_id': user_id}" invisible="((is_company and not parent_id) or company_name) and company_name != ''"/>
                            <div colspan="2" class="d-flex gap-2" invisible="not company_name or company_name == '' or is_company">
                                <label for="company_name" class="fw-bold text-nowrap"/>
                                <field name="company_name"/>
                                <button name="create_company" icon="fa-plus-square" string="Create" type="object" class="oe_edit_only btn-link text-nowrap"/>
                            </div>
                            <span class="o_form_label o_td_label o_address_type" name="address_name">
                                <field name="type_address_label" invisible="is_company" readonly="1" class="fw-bold"/>
                                <span invisible="not is_company">Address</span>
                            </span>
                            <div class="o_address_format">
                                <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" placeholder="State" class="o_address_state" options="{'no_open': True, 'no_quick_create': True}" context="{'country_id': country_id, 'default_country_id': country_id, 'zip': zip}"/>
                                <field name="zip" placeholder="ZIP" class="o_address_zip"/>
                                <div name="partner_address_country" class="d-flex justify-content-between">
                                    <field name="country_id" placeholder="Country" class="o_address_country" options="{&quot;no_open&quot;: True, &quot;no_create&quot;: True}"/>
                                </div>
                            </div>
                        </group>
                        <group>
                            <field name="function" placeholder="e.g. Sales Director" invisible="is_company"/>
                            <field name="vat" placeholder="e.g. BE0477472701"/>
                            <field name="website" string="Website" widget="url" placeholder="e.g. https://www.odoo.com"/>
                            <field name="lang" invisible="active_lang_count &lt;= 1"/>
                            <field name="category_id" widget="many2many_tags" options="{'color_field': 'color'}" placeholder="e.g. &quot;B2B&quot;, &quot;VIP&quot;, &quot;Consulting&quot;, ..."/>
                        </group>
                    </group>

                    <notebook colspan="4">
                        <page string="Contacts" name="contact_addresses" autofocus="autofocus">
                            <field name="child_ids" mode="kanban" context="{'default_parent_id': id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_lang': lang, 'default_user_id': user_id, 'default_type': is_company and 'contact' or 'other'}">
                                <kanban color="color">
                                    <field name="color"/>
                                    <field name="type"/>
                                    <field name="is_company"/>
                                    <templates>
                                        <t t-name="card" class="flex-row">
                                            <aside class="o_kanban_aside_full">
                                                <field name="avatar_128" class="o_kanban_image_fill w-100" widget="image" options="{'img_class': 'object-fit-cover'}" alt="Contact image" invisible="type != 'contact'"/>
                                                <field name="avatar_128" class="o_kanban_image_fill w-100" widget="image" options="{'img_class': 'object-fit-contain p-2'}" alt="Contact image" invisible="type == 'contact'"/>
                                            </aside>
                                            <main class="ps-2 ps-md-0">
                                                <field name="name" invisible="not name" class="fw-bold"/>
                                                <field name="type" invisible="name" class="fw-bold"/>
                                                <div t-if="record.email.raw_value" class="text-truncate">
                                                    <i class="fa fa-fw me-1 fa-envelope text-primary" title="Email"/>
                                                    <field name="email"/>
                                                </div>
                                                <div t-if="record.phone.raw_value">
                                                    <i class="fa fa-fw me-1 fa-phone text-primary" title="Phone"/>
                                                    <field name="phone"/>
                                                </div>
                                                <div invisible="not function or is_company">
                                                    <i class="fa fa-fw me-1 fa-suitcase text-primary" title="Position"/>
                                                    <field name="function"/>
                                                </div>
                                                <div t-if="record.type.raw_value != 'contact' and (record.city.raw_value or record.country_id.raw_value)">
                                                    <i class="fa fa-fw me-1 fa-map-marker text-primary" title="Location"/>
                                                    <field name="city"/>
                                                    <span t-if="record.city.raw_value and record.country_id.raw_value">, </span>
                                                    <field name="country_id"/>
                                                </div>
                                            </main>
                                        </t>
                                    </templates>
                                </kanban>
                                <form string="Contact / Address">
                                    <sheet>
                                        <field name="type" required="1" widget="radio" options="{'horizontal': true}"/>
                                        <div class="d-flex align-items-center gap-3">
                                            <field name="image_1920" widget="contact_image" nolabel="1" options="{'preview_image': 'avatar_128', 'size': [100,100], 'img_class': 'rounded border'}"/>
                                            <div class="flex-grow-1">
                                                <h3>
                                                    <field name="name" class="d-block" string="Name" default_focus="1" required="type == 'contact'" placeholder="e.g. Brandon Freeman"/>
                                                </h3>
                                                <div class="row flex-row">
                                                    <div class="d-flex align-items-baseline">
                                                        <i class="fa fa-fw me-1 fa-envelope text-primary" title="Email"/>
                                                        <field name="email" widget="email" class="w-100" context="{'gravatar_image': True}" required="user_ids" placeholder="Email"/>
                                                    </div>
                                                    <div class="d-flex align-items-baseline">
                                                        <i class="fa fa-fw me-1 fa-phone text-primary" title="Phone"/>
                                                        <field name="phone" widget="phone" class="w-100" placeholder="Phone"/>
                                                    </div>
                                                    <div invisible="is_company or type != 'contact'" class="d-flex align-items-baseline">
                                                        <i class="fa fa-fw me-1 fa-suitcase text-primary" title="Position"/>
                                                        <field name="function" placeholder="Job title"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <group invisible="type == 'contact'" name="other_info">
                                            <group>
                                                <span class="o_form_label o_td_label o_address_type">
                                                    <field name="type_address_label" readonly="1" class="fw-bold"/>
                                                </span>
                                                <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, 'no_quick_create': True}" context="{'country_id': country_id, 'default_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="{&quot;no_open&quot;: True, &quot;no_create&quot;: True}"/>
                                                </div>
                                            </group>
                                        </group>
                                        <group>
                                            <field name="company_id" invisible="1"/>    <!-- Need to save value from parented record, cf onchange -->
                                            <label for="comment"/>
                                            <field name="comment" options="{'height': 100}" placeholder="Internal notes..." nolabel="1"/>
                                        </group>
                                        <field name="lang" invisible="True"/>  <!-- Need to add lang to save default value from parented record -->
                                    </sheet>
                                </form>
                            </field>
                        </page>
                        <page name="sales_purchases" string="Sales &amp; Purchase">
                            <group name="container_row_2">
                                <group string="Sales" name="sale" priority="1">
                                    <field name="user_id" widget="many2one_avatar_user" domain="[('share', '=', False)]"/>
                                </group>
                                <group string="Purchase" name="purchase" priority="2">
                                </group>
                                <group name="misc" string="Misc">
                                    <field name="company_registry_placeholder" invisible="1"/> <!-- Needed for the placeholder widget -->
                                    <field name="company_registry" invisible="parent_id or not is_company" options="{'placeholder_field': 'company_registry_placeholder'}"/>
                                    <field name="ref" string="Reference"/>
                                    <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" readonly="parent_id" force_save="1" placeholder="Visible to all"/>
                                    <field name="company_id" invisible="1"/> <!-- need to be able to compute based on the company even without multi company groups -->
                                    <field name="industry_id" invisible="not is_company" options="{'no_create': True}"/>
                                </group>
                            </group>
                        </page>
                        <page name="internal_notes" string="Notes">
                            <field name="comment" placeholder="Internal notes..."/>
                            <group name="warnings"/>
                        </page>
                    </notebook>
                </sheet>
                </form>
            