<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="pms_property_views_form" model="ir.ui.view">
        <field name="name">pms_property_views_form</field>
        <field name="model">pms.property</field>
        <field name="arch" type="xml">
            <form string="Property Configuration">
                <sheet>
                    <label for="name" class="oe_edit_only" />
                    <h1>
                        <field name="name" class="oe_inline" />
                    </h1>
                    <label for="company_id" />
                    <field name="company_id" class="oe_inline" />
                    <field name="logo" widget="image" class="oe_avatar" />
                    <div class="col-6">
                        <label for="ref" />
                        <field name="ref" />
                    </div>
                    <div class="col-6">
                        <label for="pms_property_code" />
                        <field name="pms_property_code" />
                    </div>
                    <notebook>
                        <page string="General Information" name="property_general">
                            <group>
                                <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"
                                        class="o_address_state"
                                        placeholder="State"
                                    />
                                    <field
                                        name="zip"
                                        placeholder="ZIP"
                                        class="o_address_zip"
                                    />
                                    <field
                                        name="country_id"
                                        placeholder="Country"
                                        class="o_address_country"
                                    />
                                </div>
                            </group>
                            <group>
                                <div class="row">
                                    <div class="col-6">
                                        <label for="phone" />
                                        <field name="phone" />
                                    </div>
                                </div>
                            </group>
                        </page>
                        <page string="Settings" name="property_settings">
                            <group
                                colspan="4"
                                col="4"
                                string="Price and Availability Plans"
                            >
                                <field name="default_pricelist_id" required="True" />
                            </group>
                            <group string="Timezone">
                                <field name="tz" widget="timezone_mismatch" />
                            </group>
                            <group string="Sequences">
                                <field name="folio_sequence_id" />
                                <field name="checkin_sequence_id" />
                            </group>
                            <group colspan="4" col="4" string="Check-in hours">
                                <field name="default_arrival_hour" />
                                <field name="default_departure_hour" />
                            </group>
                            <group string="Print in cardex">
                                <field name="cardex_warning" />
                            </group>
                        </page>
                        <page string="Rooms" name="property_rooms">
                            <group>
                                <field name="room_ids" />
                            </group>
                        </page>
                        <page string="Invoicing" name="property_invoicing">
                            <group>
                                <field name="default_invoicing_policy" />
                                <field
                                    name="margin_days_autoinvoice"
                                    attrs="{'invisible': [('default_invoicing_policy', '=', 'manual')]}"
                                />
                                <field
                                    name="journal_normal_invoice_id"
                                    attrs="{'required': [('default_invoicing_policy', '!=', 'manual')]}"
                                    domain="[
                                        ('type', '=', 'sale'),
                                        ('company_id','=',company_id),
                                    ]"
                                />
                                <field
                                    name="journal_simplified_invoice_id"
                                    attrs="{'required': [('default_invoicing_policy', '!=', 'manual')]}"
                                    domain="[
                                        ('type', '=', 'sale'),
                                        ('company_id','=',company_id),
                                    ]"
                                />
                                <field name="max_amount_simplified_invoice" />
                                <field name="avoid_simplified_max_amount_downpayment" />
                            </group>
                        </page>
                        <page string="Email Configuration">
                            <group>
                                <div class="row">
                                    <div class="col-6">
                                        <group
                                            string="Email Templates"
                                            name="email_templates"
                                        >
                                            <field
                                                string="Confirmation Email"
                                                name="property_confirmed_template"
                                            />
                                            <field
                                                string="Modification Email"
                                                name="property_modified_template"
                                            />
                                            <field
                                                string="Cancellation Email"
                                                name="property_canceled_template"
                                            />
                                            <field
                                                string="Exit Email"
                                                name="property_exit_template"
                                            />
                                        </group>
                                    </div>
                                    <div class="col-6">
                                        <group string="Auto Send Email">
                                            <field
                                                name="is_confirmed_auto_mail"
                                                string="Confirmation Email"
                                            />
                                            <field
                                                name="is_modified_auto_mail"
                                                string="Modification Email"
                                            />
                                            <field
                                                name="is_canceled_auto_mail"
                                                string="Cancellation Email"
                                            />
                                        </group>
                                    </div>
                                </div>
                            </group>
                            <group
                                string="Mail Information"
                                name="mail_information"
                                colspan="4"
                            >
                                <field
                                    name="mail_information"
                                    string="Aditional Mail Information"
                                />
                                <field name="privacy_policy" />
                            </group>
                        </page>
                        <page name="members" string="Team Members">
                            <label for="user_id" string="Team Leader" />
                            <h3>
                                <field name="user_id" options="{'no_create': True}" />
                            </h3>
                            <field
                                name="member_ids"
                                mode="kanban"
                                context="{'default_pms_property_id': active_id}"
                            >
                                <kanban
                                    on_create="quick_create"
                                    quick_create_view="pms.pms_team_member_view_form"
                                    delete="true"
                                    sample="1"
                                >
                                    <field name="id" />
                                    <field name="name" />
                                    <field name="user_id" />
                                    <field name="pms_role" />
                                    <field name="pms_property_id" invisible="1" />
                                    <templates>
                                        <t t-name="kanban-box">
                                            <div
                                                class="oe_kanban_global_click"
                                                style="max-width: 200px"
                                            >
                                                <div class="o_kanban_record_top">
                                                    <img
                                                        t-att-src="kanban_image('res.users', 'image_128', record.user_id.raw_value)"
                                                        class="oe_avatar oe_kanban_avatar_smallbox o_image_40_cover mb0"
                                                        alt="Avatar"
                                                    />
                                                    <div class="oe_kanban_content">
                                                        <div>
                                                            <strong
                                                                class="o_kanban_record_title"
                                                            >
                                                                <field
                                                                    name="pms_role"
                                                                />
                                                            </strong>
                                                        </div>
                                                        <div>
                                                            <field name="name" />
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="oe_clear" />
                                            </div>
                                        </t>
                                    </templates>
                                </kanban>
                                <form string="Member Team">
                                    <sheet>
                                        <div class="oe_title">
                                            <label for="name" />
                                            <h1>
                                                <field name="name" />
                                            </h1>
                                        </div>
                                        <group>
                                            <field name="user_id" />
                                            <field name="pms_role" />
                                        </group>
                                    </sheet>
                                </form>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
    <record id="pms_property_views_tree" model="ir.ui.view">
        <field name="name">pms_property_views_tree</field>
        <field name="model">pms.property</field>
        <field name="arch" type="xml">
            <tree name="Property settings summary">
                <field name="name" />
                <field name="company_id" />
            </tree>
        </field>
    </record>
    <!-- actions -->
    <record id="pms_property_action" model="ir.actions.act_window">
        <field name="name">Properties</field>
        <field name="res_model">pms.property</field>
        <field name="view_mode">tree,form</field>
    </record>
    <!-- menus -->
    <menuitem
        action="pms_property_action"
        id="general_property_menu"
        parent="base.menu_users"
        sequence="10"
        name="Properties"
    />
    <menuitem
        action="pms_property_action"
        id="pms_property_menu"
        parent="pms.pms_configuration_menu"
        sequence="65"
        name="Properties"
    />
</odoo>
