recruitment fixes

This commit is contained in:
pranaysaidurga 2026-06-25 17:05:21 +05:30
parent 77827a188f
commit 08569e0ae0
3 changed files with 39 additions and 9 deletions

View File

@ -483,6 +483,10 @@ class HrRecruitmentAutoDocWizard(models.TransientModel):
} }
def _get_jd_required_fields(self): def _get_jd_required_fields(self):
category_dict = {
str(category['id']): category['category_name']
for category in self.env['job.category'].sudo().search_read([], ['id', 'category_name'])
}
return { return {
"request_id": {"type": "string", "description": "Request or requisition identifier"}, "request_id": {"type": "string", "description": "Request or requisition identifier"},
"start_date": {"type": "string", "description": "Requested start date"}, "start_date": {"type": "string", "description": "Requested start date"},
@ -495,6 +499,7 @@ class HrRecruitmentAutoDocWizard(models.TransientModel):
"secondary_skills": {"type": "list", "description": "Secondary or nice to have skills"}, "secondary_skills": {"type": "list", "description": "Secondary or nice to have skills"},
"budget": {"type": "string", "description": "Budget or salary range"}, "budget": {"type": "string", "description": "Budget or salary range"},
"experience_years": {"type": "float", "description": "Expected total years of experience"}, "experience_years": {"type": "float", "description": "Expected total years of experience"},
"job_category": {"type": "selection", "description": "Based on over all Job description which one matches more accurately give me the key: %s"%(category_dict)}
} }
def _get_resume_prompt(self): def _get_resume_prompt(self):
@ -1766,8 +1771,11 @@ class HrRecruitmentAutoDocWizard(models.TransientModel):
"secondary_skill_ids": [(6, 0, secondary_skills.ids)] if secondary_skills else False, "secondary_skill_ids": [(6, 0, secondary_skills.ids)] if secondary_skills else False,
} }
job_category = self._match_job_category(parsed_data, parsed_payload) job_category = self._match_job_category(parsed_data, parsed_payload)
if job_category:
write_vals["job_category"] = job_category.id if job_request and job_request.job_category:
if job_request.job_id and job_request.job_id.job_category != job_request.job_category:
job_request.job_id.job_category = job_request.job_category.id
elif job_category:
if job_request.job_id and job_request.job_id.job_category != job_category: if job_request.job_id and job_request.job_id.job_category != job_category:
job_request.job_id.job_category = job_category.id job_request.job_id.job_category = job_category.id
write_vals = {key: value for key, value in write_vals.items() if value not in (False, None, "")} write_vals = {key: value for key, value in write_vals.items() if value not in (False, None, "")}
@ -1805,7 +1813,14 @@ class HrRecruitmentAutoDocWizard(models.TransientModel):
job_category = self._match_job_category(parsed_data, parsed_payload) job_category = self._match_job_category(parsed_data, parsed_payload)
if job_category and job.job_category != job_category: if job_category and job.job_category != job_category:
job.job_category = job_category.id job.job_category = job_category.id
category_dict = {
str(category['id']): category['category_name']
for category in self.env['job.category'].search_read([], ['id', 'category_name'])
}
reverse_category = {v: k for k, v in category_dict.items()}
job_category = parsed_data.get("job_category")
job_category_id = reverse_category.get(job_category, job_category)
create_vals = { create_vals = {
"job_id": job.id, "job_id": job.id,
"company_id": self.env.company.id, "company_id": self.env.company.id,
@ -1813,12 +1828,17 @@ class HrRecruitmentAutoDocWizard(models.TransientModel):
"requirements": parsed_data.get("requirements"), "requirements": parsed_data.get("requirements"),
"target_from": self._parse_date_value(parsed_data.get("start_date")), "target_from": self._parse_date_value(parsed_data.get("start_date")),
"target_to": self._parse_date_value(parsed_data.get("end_date")), "target_to": self._parse_date_value(parsed_data.get("end_date")),
"job_category": job_category.id if job_category else False, "job_category": int(job_category_id) if job_category_id and job_category_id.isdigit() else False,
"address_id":False,
"recruitment_type": 'external'
} }
if request_id: if request_id:
create_vals["recruitment_sequence"] = request_id create_vals["recruitment_sequence"] = request_id
create_vals = {key: value for key, value in create_vals.items() if value not in (False, None, "")} create_vals = {key: value for key, value in create_vals.items() if value not in (False, None, "")}
return job_request_model.create(create_vals), "created" job_request = job_request_model.create(create_vals)
job_request.sudo().write({"address_id" : False})
return job_request, "created"
def _match_existing_job_position(self, job_title): def _match_existing_job_position(self, job_title):
hr_job_model = self.env["hr.job"] hr_job_model = self.env["hr.job"]

View File

@ -5,10 +5,10 @@
<field name="model">hr.recruitment.auto.doc.wizard</field> <field name="model">hr.recruitment.auto.doc.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Parse Recruitment Documents" create="0" edit="1"> <form string="Parse Recruitment Documents" create="0" edit="1">
<header> <!-- <header>-->
<button name="action_parse_documents" string="Parse Documents" type="object" class="btn-primary" invisible="not attachment_ids and not resume_file"/> <!-- <button name="action_parse_documents" string="Parse Documents" type="object" class="btn-primary" invisible="not attachment_ids and not resume_file"/>-->
<!-- <button string="Close" special="cancel" class="btn-secondary"/>--> <!--&lt;!&ndash; <button string="Close" special="cancel" class="btn-secondary"/>&ndash;&gt;-->
</header> <!-- </header>-->
<sheet> <sheet>
<group> <group>
<group> <group>
@ -39,7 +39,15 @@
invisible="1"/> invisible="1"/>
</group> </group>
<group string="Uploaded Files"> <div class="text-end">
<button name="action_parse_documents"
string="Parse Documents"
type="object"
class="btn-primary"
invisible="not attachment_ids and not resume_file"/>
</div>
<group string="Uploaded Files" invisible="not line_ids">
<field name="line_ids" nolabel="1" readonly="1"> <field name="line_ids" nolabel="1" readonly="1">
<kanban class="o_kanban_small_column"> <kanban class="o_kanban_small_column">
<templates> <templates>

View File

@ -429,6 +429,7 @@
<field name="name">Job Positions Recruitment</field> <field name="name">Job Positions Recruitment</field>
<field name="res_model">hr.job.recruitment</field> <field name="res_model">hr.job.recruitment</field>
<field name="view_mode">kanban,list,form</field> <field name="view_mode">kanban,list,form</field>
<field name="domain"></field>
<field name="search_view_id" ref="view_job_recruitment_filter"/> <field name="search_view_id" ref="view_job_recruitment_filter"/>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_smiling_face"> <p class="o_view_nocontent_smiling_face">
@ -446,6 +447,7 @@
<field name="res_model">hr.job.recruitment</field> <field name="res_model">hr.job.recruitment</field>
<field name="view_mode">kanban,list,form,search</field> <field name="view_mode">kanban,list,form,search</field>
<field name="search_view_id" ref="view_job_recruitment_filter"/> <field name="search_view_id" ref="view_job_recruitment_filter"/>
<field name="domain"></field>
<field name="context">{"search_default_open_status":1,"search_default_my_assignments":1}</field> <field name="context">{"search_default_open_status":1,"search_default_my_assignments":1}</field>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_smiling_face"> <p class="o_view_nocontent_smiling_face">