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

    <!-- Work Location Form View -->
    <record id="payroll_work_location_view_form" model="ir.ui.view">
        <field name="name">payroll.work.location.form</field>
        <field name="model">payroll.work.location</field>
        <field name="arch" type="xml">
            <form string="Work Location">
                <header>
                    <field name="status" widget="statusbar" statusbar_visible="active,inactive"/>
                </header>
                <sheet>
                    <group>
                        <group>
                            <field name="name" placeholder="Location name"/>
                            <field name="company_id" invisible="1"/>
                            <field name="is_primary"/>
                        </group>
                        <group>
                            <field name="employee_count" readonly="1"/>
                        </group>
                    </group>
                    <group string="Address">
                        <group>
                            <field name="street" placeholder="Street address"/>
                            <field name="street2" placeholder="Apt, Suite, Unit (optional)"/>
                            <field name="city" placeholder="City"/>
                        </group>
                        <group>
                            <field name="state_id" placeholder="Province"/>
                            <field name="zip" placeholder="Postal code"/>
                            <field name="country_id" placeholder="Country"/>
                        </group>
                    </group>
                    <group string="Employees">
                        <field name="employee_ids" widget="many2many_tags" 
                               options="{'color_field': 'employment_status'}"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Work Location List View -->
    <record id="payroll_work_location_view_tree" model="ir.ui.view">
        <field name="name">payroll.work.location.list</field>
        <field name="model">payroll.work.location</field>
        <field name="arch" type="xml">
            <list string="Work Locations">
                <field name="name"/>
                <field name="street"/>
                <field name="city"/>
                <field name="state_id"/>
                <field name="zip"/>
                <field name="employee_count" string="Employees Assigned"/>
                <field name="status"/>
                <field name="is_primary" widget="boolean_toggle"/>
            </list>
        </field>
    </record>

    <!-- Work Location Kanban View -->
    <record id="payroll_work_location_view_kanban" model="ir.ui.view">
        <field name="name">payroll.work.location.kanban</field>
        <field name="model">payroll.work.location</field>
        <field name="arch" type="xml">
            <kanban default_order="is_primary desc, name">
                <field name="name"/>
                <field name="is_primary"/>
                <field name="employee_count"/>
                <field name="status"/>
                <templates>
                    <t t-name="kanban-box">
                        <div class="oe_kanban_card oe_kanban_global_click">
                            <div class="oe_kanban_content">
                                <div class="o_kanban_record_top">
                                    <div class="o_kanban_record_headings">
                                        <strong class="o_kanban_record_title">
                                            <field name="name"/>
                                        </strong>
                                        <span class="badge badge-pill text-bg-primary" 
                                              t-if="record.is_primary.raw_value">PRIMARY</span>
                                    </div>
                                </div>
                                <div class="o_kanban_record_body">
                                    <div>
                                        <field name="street"/>
                                        <field name="city"/>
                                        <field name="state_id"/>
                                        <field name="zip"/>
                                    </div>
                                    <div class="mt-2">
                                        <span><field name="employee_count"/> employees</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>

    <!-- Work Location Action -->
    <record id="action_payroll_work_location" model="ir.actions.act_window">
        <field name="name">Work Locations</field>
        <field name="res_model">payroll.work.location</field>
        <field name="view_mode">kanban,list,form</field>
        <field name="context">{}</field>
    </record>

</odoo>
