<odoo>

    <record model="ir.actions.act_window" id="action_hr_job_new_application">
        <field name="name">New Application</field>
        <field name="res_model">hr.applicant</field>
        <field name="view_mode">form</field>
        <field name="context">{'search_default_job_id': [active_id], 'default_job_id': active_id}</field>
    </record>

    <record id="view_hr_job_kanban" model="ir.ui.view">
        <field name="name">hr.job.kanban</field>
        <field name="model">hr.job</field>
        <field name="arch" type="xml">
            <kanban class="o_kanban_dashboard o_hr_recruitment_kanban" on_create="hr_recruitment.create_job_simple" sample="1" limit="40" action="%(action_hr_job_applications)d" type="action">
                <field name="active"/>
                <field name="name"/>
                <field name="alias_email"/>
                <field name="is_favorite"/>
                <field name="department_id"/>
                <field name="no_of_recruitment"/>
                <field name="color"/>
                <field name="new_application_count"/>
                <field name="no_of_hired_employee"/>
                <field name="manager_id"/>
                <field name="user_id"/>
                <field name="application_count"/>
                <templates>
                    <t t-name="kanban-menu" groups="hr_recruitment.group_hr_recruitment_user">
                        <div class="container">
                            <div class="row">
                                <div class="col-6 o_kanban_card_manage_section">
                                    <h5 role="menuitem" class="o_kanban_card_manage_title">
                                        <span>View</span>
                                    </h5>
                                    <div role="menuitem" name="menu_view_applications">
                                        <a name="%(action_hr_job_applications)d" type="action">Applications</a>
                                    </div>
                                    <div role="menuitem">
                                        <a name="action_open_activities" type="object">Activities</a>
                                    </div>
                                    <div role="menuitem">
                                        <a name="%(action_hr_job_sources)d" type="action" context="{'default_job_id': id}">Trackers</a>
                                    </div>
                                </div>
                                <div class="col-6 o_kanban_card_manage_section">
                                    <h5 role="menuitem" class="o_kanban_card_manage_title">
                                        <span>New</span>
                                    </h5>
                                    <div role="menuitem" name="menu_new_applications">
                                        <a name="%(hr_recruitment.action_hr_applicant_new)d" type="action">Application</a>
                                    </div>
                                </div>
                                <div class="col-6 o_kanban_card_manage_section">
                                    <h5 role="menuitem" class="o_kanban_card_manage_title">
                                        <span>Reporting</span>
                                    </h5>
                                    <div role="menuitem" name="o_kanban_job_reporting">
                                        <a name="%(hr_recruitment.action_hr_recruitment_report_filtered_job)d" type="action">Analysis</a>
                                    </div>
                                </div>
                            </div>
                            <div class="o_kanban_card_manage_settings row">
                                <div class="col-6" role="menuitem" aria-haspopup="true">
                                    <ul class="oe_kanban_colorpicker" data-field="color" role="popup"/>
                                </div>
                                <div class="col-6" role="menuitem">
                                    <a class="dropdown-item" t-if="widget.editable" name="edit_job" type="edit">Configuration</a>
                                    <a class="dropdown-item" t-if="record.active.raw_value" name="toggle_active" type="object">Archive</a>
                                    <a class="dropdown-item" t-if="!record.active.raw_value" name="toggle_active" type="object">Unarchive</a>
                                </div>
                            </div>
                        </div>
                    </t>
                    <t t-name="kanban-box">
                        <div t-attf-class="#{!selection_mode ? kanban_color(record.color.raw_value) : ''}">
                            <div class="o_kanban_card_header d-flex align-items-baseline gap-1">
                                <field name="is_favorite" widget="boolean_favorite" nolabel="1"/>
                                <div class="o_kanban_card_header_title">
                                    <div class="o_primary">
                                        <span><t t-esc="record.name.value"/></span>
                                    </div>
                                    <div class="text-muted">
                                        <field name="user_id" />
                                    </div>
                                    <div class="o_secondary" groups="base.group_multi_company">
                                        <small><i class="fa fa-building-o" role="img" aria-label="Company" title="Company"></i> <field name="company_id"/></small>
                                    </div>
                                    <div t-if="record.alias_email.value" class="o_secondary o_job_alias">
                                        <small><i class="fa fa-envelope-o" role="img" aria-label="Alias" title="Alias"></i> <field name="alias_id"/></small>
                                    </div>
                                </div>
                            </div>
                            <div class="container o_recruitment_job_container o_kanban_card_content mt-0 mt-sm-3">
                                <div class="row">
                                    <div class="col-7">
                                        <button class="btn btn-primary" name="%(action_hr_job_applications)d" type="action">
                                            <field name="new_application_count"/> New Applications
                                        </button>
                                    </div>
                                    <ul class="col-5 o_job_activities">
                                        <li>
                                            <a name="edit_job" type="edit" t-attf-class="{{ record.no_of_recruitment.raw_value > 0 ? 'text-primary fw-bolder' : 'text-secondary' }}" groups="hr_recruitment.group_hr_recruitment_user">
                                                <field name="no_of_recruitment"/> To Recruit
                                            </a>
                                            <span t-attf-class="{{ record.no_of_recruitment.raw_value > 0 ? 'text-primary fw-bolder' : 'text-secondary' }}" groups="!hr_recruitment.group_hr_recruitment_user">
                                                <field name="no_of_recruitment"/> To Recruit
                                            </span>
                                        </li>
                                        <li t-if="record.application_count.raw_value > 0">
                                            <field name="application_count"/> Applications
                                        </li>
                                        <li class="text-warning" t-if="record.activities_today.raw_value > 0">
                                            <a name="action_open_today_activities" type="object" class="text-warning"><field name="activities_today"/> Activities Today</a>
                                        </li>
                                        <li t-if="record.activities_overdue.raw_value > 0">
                                            <a name="action_open_late_activities" type="object" class="text-danger"><field name="activities_overdue"/> Late Activities</a>
                                        </li>
                                    </ul>
                                </div>
                                <div name="kanban_boxes" class="row flex-nowrap" groups="hr_recruitment.group_hr_recruitment_user"></div>
                            </div>
                        </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>
    <record id="view_job_filter_recruitment" model="ir.ui.view">
        <field name="name">Job</field>
        <field name="model">hr.job</field>
        <field name="inherit_id" ref="hr.view_job_filter"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='department_id']" position="after">
                <filter string="My Favorites" name="my_favorite_jobs" domain="[('favorite_user_ids', 'in', uid)]"/>
                <separator/>
            </xpath>
        </field>
    </record>

    <record id="hr_job_simple_form" model="ir.ui.view">
        <field name="name">hr.job.simple.form</field>
        <field name="model">hr.job</field>
        <field name="priority">200</field>
        <field name="arch" type="xml">
            <form string="Create a Job Position" class="o_hr_job_simple_form" >
                <group>
                    <field name="name" class="o_job_name oe_inline" placeholder="e.g. Sales Manager"/>
                    <label for="alias_name" string="Application email"
                           help="Define a specific contact address for this job position. If you keep it empty, the default email address will be used which is in human resources settings"/>
                    <div name="alias_def">
                        <field name="alias_id" class="oe_read_only" string="Email Alias" required="0"/>
                        <div class="oe_edit_only" name="edit_alias">
                            <field name="alias_name" class="oe_inline o_job_alias" placeholder="e.g. sales-manager"/>@
                            <field name="alias_domain_id" class="oe_inline" placeholder="e.g. domain.com"
                                   options="{'no_create': True, 'no_open': True}"/>
                        </div>
                        <div class="text-muted">Applicants can send resume to this email address,<br/>it will create an application automatically</div>
                    </div>
                </group>
                <footer>
                    <button string="Create" type="object" name="close_dialog" class="btn-primary o_create_job" data-hotkey="q"/>
                    <button string="Discard" class="btn-secondary" special="cancel" data-hotkey="x"/>
                </footer>
            </form>
        </field>
    </record>

    <record id="create_job_simple" model="ir.actions.act_window">
        <field name="name">Create a Job Position</field>
        <field name="res_model">hr.job</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="hr_job_simple_form"/>
        <field name="target">new</field>
        <field name="context">{'dialog_size' : 'medium'}</field>
    </record>

    <record id="hr_job_survey" model="ir.ui.view">
        <field name="name">hr.job.form1</field>
        <field name="model">hr.job</field>
        <field name="inherit_id" ref="hr.view_hr_job_form"/>
        <field name="arch" type="xml">
            <div name="recruitment_target" position="after">
                <field name="user_id" widget="many2one_avatar_user"/>
                <field name="interviewer_ids" widget="many2many_tags_avatar" options="{'no_create': True, 'no_create_edit': True}" />
            </div>
            <xpath expr="//field[@name='department_id']" position="after">
                <label for="address_id"/>
                <div class="o_row">
                    <span invisible="address_id" class="oe_read_only">Remote</span>
                    <field name="address_id" context="{'show_address': 1}" placeholder="Remote"/>
                </div>
                <label for="alias_name" string="Email Alias"
                       help="Define a specific contact address for this job position. If you keep it empty, the default email address will be used which is in human resources settings"/>
                <div name="alias_def">
                    <field name="alias_id" class="oe_read_only" string="Email Alias" required="0"/>
                    <div class="oe_edit_only" name="edit_alias">
                        <field name="alias_name" class="oe_inline"/>@
                        <field name="alias_domain_id" class="oe_inline" placeholder="e.g. domain.com"
                               options="{'no_create': True, 'no_open': True}"/>
                    </div>
                </div>
            </xpath>
            <xpath expr="//field[@name='contract_type_id']" position="after">
                <field name="company_id" groups="base.group_multi_company"/>
            </xpath>
            <div name="button_box" position="inside">
                <button class="oe_stat_button"
                    icon="fa-pencil"
                    name="%(action_hr_job_applications)d"
                    context="{'default_user_id': user_id, 'active_test': False}"
                    type="action">
                    <field name="all_application_count" widget="statinfo" string="Job Applications"/>
                </button>
                <button class="oe_stat_button"
                    icon="fa-file-text-o"
                    name="action_open_attachments"
                    type="object"
                    invisible="documents_count == 0">
                    <field name="documents_count" widget="statinfo" string="Documents"/>
                </button>
                <button class="oe_stat_button" type="action"
                    name="%(action_hr_job_sources)d" icon="fa-bar-chart-o"
                    context="{'default_job_id': id}">
                    <div class="o_field_widget o_stat_info">
                        <span class="o_stat_text">Trackers</span>
                    </div>
                </button>
            </div>
        </field>
    </record>

    <!-- hr related job position menu action -->
    <record model="ir.actions.act_window" id="action_hr_job_config">
        <field name="name">Job Positions</field>
        <field name="res_model">hr.job</field>
        <field name="view_mode">tree,kanban,form</field>
        <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'tree', 'view_id': ref('hr.view_hr_job_tree')}),
            (0, 0, {'view_mode': 'kanban', 'view_id': ref('hr.hr_job_view_kanban')}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('hr.view_hr_job_form')})]"/>
        <field name="context">{'search_default_in_recruitment': 1}</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Ready to recruit more efficiently?
            </p><p>
                Let's create a job position.
            </p>
        </field>
    </record>

    <record id="hr_job_search_view" model="ir.ui.view">
        <field name="name">hr.job.search</field>
        <field name="model">hr.job</field>
        <field name="inherit_id" ref="hr_recruitment.view_job_filter_recruitment" />
        <field name="priority">20</field>
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='my_favorite_jobs']" position="after">
                <searchpanel>
                    <field name="company_id" groups="base.group_multi_company" icon="fa-building" enable_counters="1"/>
                    <field name="department_id" icon="fa-users" enable_counters="1"/>
                </searchpanel>
                <filter string="My Job Positions" name="my_positions" domain="[('user_id', '=', uid)]"/>
            </xpath>
        </field>
    </record>

    <record id="hr_job_view_tree_inherit" model="ir.ui.view">
        <field name="model">hr.job</field>
        <field name="inherit_id" ref="hr.view_hr_job_tree"/>
        <field name="arch" type="xml">
            <field name="department_id" position="after">
                <field name="application_count" string="Applications"/>
            </field>
            <field name="no_of_recruitment" position="after">
                <field name="alias_name" column_invisible="True"/>
                <field name="alias_id" invisible="not alias_name" optional="hide"/>
                <field name="user_id" widget="many2one_avatar_user" optional="hide"/>
            </field>
        </field>
    </record>

    <!-- hr related job position menu action -->
    <record model="ir.actions.act_window" id="action_hr_job">
        <field name="name">Job Positions</field>
        <field name="res_model">hr.job</field>
        <field name="view_mode">kanban,tree,form</field>
        <field name="view_id" ref="hr_recruitment.view_hr_job_kanban"/>
        <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'kanban', 'view_id': ref('hr_recruitment.view_hr_job_kanban')}),
            (0, 0, {'view_mode': 'tree', 'view_id': ref('hr_recruitment.hr_job_view_tree_inherit')}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('hr.view_hr_job_form')})]"/>
        <field name="context">{}</field>
        <field name="help" type="html">
          <p class="o_view_nocontent_smiling_face">
              Ready to recruit more efficiently?
          </p><p>
              Let's create a job position.
          </p>
        </field>
    </record>
    <menuitem name="By Job Positions" parent="menu_crm_case_categ0_act_job"
        id="menu_hr_job_position" action="action_hr_job"
        sequence="1" groups="hr_recruitment.group_hr_recruitment_user" />

    <!-- Job Positions filtered for interviewers -->
    <record model="ir.actions.act_window" id="action_hr_job_interviewer">
        <field name="name">Job Positions</field>
        <field name="res_model">hr.job</field>
        <field name="view_mode">kanban,form</field>
        <field name="view_id" ref="hr_recruitment.view_hr_job_kanban"/>
        <field name="context">{'create': False}</field>
        <field name="domain">[
            '|',
                ('interviewer_ids', 'in', uid),
                ('extended_interviewer_ids', 'in', uid),
        ]</field>
    </record>
    <menuitem name="By Job Positions" parent="menu_crm_case_categ0_act_job"
        id="menu_hr_job_position_interviewer" action="action_hr_job_interviewer"
        sequence="1" groups="hr_recruitment.group_hr_recruitment_interviewer" />
</odoo>
