<?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">
                  A partner with the same <span><field name="vat_label"/></span> already exists (<field name="same_vat_partner_id" context="{'show_address': False, 'show_vat': False}"/>), are you sure you want to create a new one?
                </div>
                <div class="alert alert-warning oe_edit_only" role="alert" name="warning_company" invisible="not same_company_registry_partner_id">
                  A partner with the same <span><field name="company_registry_label"/></span> already exists (<field name="same_company_registry_partner_id" context="{'show_address': False, 'show_vat': False}"/>), are you sure you want to create a new one?
                </div>
                <sheet>
                    <div class="oe_button_box" name="button_box"/>
                    <widget name="web_ribbon" title="Archived" bg_color="text-bg-danger" invisible="active"/>
                    <field name="image_1920" widget="image" class="oe_avatar" options="{&quot;preview_image&quot;: &quot;avatar_128&quot;}"/>
                    <div class="oe_title mb24">
                        <field name="company_type" widget="radio" options="{'horizontal': true}"/>
                        <h1>
                            <field id="company" options="{'line_breaks': False}" widget="text" class="text-break" name="name" default_focus="1" placeholder="e.g. Lumber Inc" invisible="not is_company" required="type == 'contact'"/>
                            <field id="individual" options="{'line_breaks': False}" widget="text" class="text-break" name="name" default_focus="1" placeholder="e.g. Brandon Freeman" invisible="is_company" required="type == 'contact'"/>
                        </h1>
                        <div class="o_row">
                            <field name="parent_id" widget="res_partner_many2one" placeholder="Company Name..." domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'show_vat': True, 'default_user_id': user_id}" invisible="((is_company and not parent_id) or company_name) and company_name != ''"/>
                                <field name="company_name" invisible="not company_name or company_name == '' or is_company"/>
                                <button name="create_company" icon="fa-plus-square" string="Create company" type="object" class="oe_edit_only btn-link" invisible="is_company or company_name == '' or not company_name"/>
                        </div>
                    </div>

                    <group>
                        <group>
                            <span class="o_form_label o_td_label o_address_type" name="address_name">
                                <field name="type" invisible="is_company" readonly="user_ids" required="not is_company" 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" readonly="type == 'contact' and parent_id"/>
                                <field name="street2" placeholder="Street 2..." class="o_address_street" readonly="type == 'contact' and parent_id"/>
                                <field name="city" placeholder="City" class="o_address_city" readonly="type == 'contact' and parent_id"/>
                                <field name="state_id" class="o_address_state" placeholder="State" options="{'no_open': True, 'no_quick_create': True}" readonly="type == 'contact' and parent_id" context="{'country_id': country_id, 'default_country_id': country_id, 'zip': zip}"/>
                                <field name="zip" placeholder="ZIP" class="o_address_zip" readonly="type == 'contact' and parent_id"/>
                                <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}" readonly="type == 'contact' and parent_id"/>
                                </div>
                            </div>
                            <field name="vat" placeholder="e.g. BE0477472701" readonly="parent_id"/>
                        </group>
                        <group>
                            <field name="function" placeholder="e.g. Sales Director" invisible="is_company"/>
                            <field name="phone" widget="phone"/>
                            <field name="mobile" widget="phone"/>
                            <field name="email" widget="email" context="{'gravatar_image': True}" required="user_ids"/>
                            <field name="website" string="Website" widget="url" placeholder="e.g. https://www.odoo.com"/>
                            <field name="title" options="{&quot;no_open&quot;: True}" placeholder="e.g. Mister" invisible="is_company"/>
                            <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 &amp; Addresses" 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': '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"/>
                                            </aside>
                                            <main class="ps-2 ps-md-0">
                                                <field name="name" class="fw-bold"/>
                                                <field name="function"/>
                                                <field name="email" widget="email"/>
                                                <div t-if="record.type.raw_value != 'contact'">
                                                    <div>
                                                        <field class="me-1" name="zip"/>
                                                        <field name="city"/>
                                                    </div>
                                                    <field class="me-1" name="state_id"/>
                                                    <field name="country_id"/>
                                                </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>
                                            </main>
                                        </t>
                                    </templates>
                                </kanban>
                                <form string="Contact / Address">
                                    <sheet>
                                        <field name="type" required="1" widget="radio" options="{'horizontal': true}"/>
                                        <div class="text-muted oe_edit_only">
                                            <p class="mb-0" invisible="type != 'contact'">
                                                <span>Use this to organize the contact details of employees of a given company (e.g. CEO, CFO, ...).</span>
                                            </p>
                                            <p class="mb-0" invisible="type != 'invoice'">
                                                <span>Preferred address for all invoices. Selected by default when you invoice an order that belongs to this company.</span>
                                            </p>
                                            <p class="mb-0" invisible="type != 'delivery'">
                                                <span>Preferred address for all deliveries. Selected by default when you deliver an order that belongs to this company.</span>
                                            </p>
                                            <p class="mb-0" invisible="type != 'other'">
                                                <span>Other address for the company (e.g. subsidiary, ...)</span>
                                            </p>
                                        </div>
                                        <hr/>
                                        <group>
                                            <group>
                                                <field name="name" string="Contact Name" required="type == 'contact'" placeholder="e.g. New Address"/>
                                                <field name="title" options="{'no_open': True}" placeholder="e.g. Mr." invisible="type != 'contact'"/>
                                                <field name="function" placeholder="e.g. Sales Director" invisible="type != 'contact'"/>
                                                <label for="street" string="Address" invisible="type == 'contact'"/>
                                                <div invisible="type == 'contact'">
                                                    <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>
                                                </div>
                                            </group>
                                            <group>
                                                <field name="email" widget="email"/>
                                                <field name="phone" widget="phone"/>
                                                <field name="mobile" widget="phone"/>
                                                <field name="company_id" invisible="1"/>    <!-- Need to save value from parented record, cf onchange -->
                                            </group>
                                        </group>
                                        <group>
                                            <field name="comment" 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" invisible="parent_id"/>
                                    <field name="ref" string="Reference"/>
                                    <field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" readonly="parent_id" force_save="1"/>
                                    <field name="company_id" invisible="1"/> <!-- need to be able to 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="Internal Notes">
                            <field name="comment" placeholder="Internal notes..."/>
                        </page>
                    </notebook>
                </sheet>
                </form>
            