[FIX] hr_recruitment: passing ids instead of objects while creating an employee

This traceback arises when the user clicks the 'Create Employee' button
from 'recruitment'

To reproduce this issue:

1) Install 'hr_recruitment' and 'Website'
2) Open 'Recruitment' and click on the 'Job Page' button of any published
   'Job Position'.
3) Click on ' Apply Now ' and apply for that job.
4) Now open that job application from 'Recruitment/Application/By job positions'
5) Change the stage from 'New' to 'Contract Signed'.
6) A button 'Create Employee' will appear, click on that.

Error:- "psycopg2.ProgrammingError: can't adapt type 'res.country'" will appear.

On the 'create_employee_from_applicant' method, the employee record is created
by using '_get_employee_create_vals' method.

In that '_get_employee_create_vals' method, 'private_country_id' is created
from 'address_sudo.country_id' which is an object.

See:-
https://github.com/odoo/odoo/blob/a5911b7d560a4e259570cf9d46fff5fb286e3d62/addons/hr_recruitment/models/hr_applicant.py#L587-L605

Here in the above use-case instead of passing 'ID', an Object is passed.
Which leads to the above traceback.

Sentry-4450017781

closes odoo/odoo#136121

X-original-commit: e462e9891fa909b04a21aa7b11e8b8f26688cc04
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
This commit is contained in:
alsh-odoo
2023-09-21 23:54:26 +00:00
parent abae4d4a5c
commit 1bccc95bbd
+2 -2
View File
@@ -619,9 +619,9 @@ class Applicant(models.Model):
'private_street': address_sudo.street,
'private_street2': address_sudo.street2,
'private_city': address_sudo.city,
'private_state_id': address_sudo.state_id,
'private_state_id': address_sudo.state_id.id,
'private_zip': address_sudo.zip,
'private_country_id': address_sudo.country_id,
'private_country_id': address_sudo.country_id.id,
'private_phone': address_sudo.phone,
'private_email': address_sudo.email,
'lang': address_sudo.lang,