[FIX] hr_recruitment: OdooBot assigned as Applicant Responsible

When someone is applying to any job position from the website
( via the `/website_form/` route ), the `hr.applicant` record
is created by OdooBot, and in such case, the `_compute_user`
method is never triggered as the field `user_id` (Responsible)
already has self.env.uid as default value.

This fix will in priority try to set a proper Responsible (if any
is defined on the job position) via `_compute_user` and then
assign `self.env.uid` if none is found.

closes odoo/odoo#55146

X-original-commit: e9292cb424ec04823dbce964ad4532edc20190c6
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
This commit is contained in:
Arnaud Baes
2020-07-29 14:01:42 +00:00
parent 8a6a4766d9
commit e106c6af7f
@@ -115,7 +115,7 @@ class Applicant(models.Model):
company_id = fields.Many2one('res.company', "Company", compute='_compute_company', store=True, readonly=False, tracking=True)
user_id = fields.Many2one(
'res.users', "Responsible", compute='_compute_user',
tracking=True, default=lambda self: self.env.uid, store=True, readonly=False)
tracking=True, store=True, readonly=False)
date_closed = fields.Datetime("Closed", compute='_compute_date_closed', store=True, index=True)
date_open = fields.Datetime("Assigned", readonly=True, index=True)
date_last_stage_update = fields.Datetime("Last Stage Update", index=True, default=fields.Datetime.now)
@@ -250,8 +250,8 @@ class Applicant(models.Model):
@api.depends('job_id')
def _compute_user(self):
for applicant in self.filtered(lambda a: a.job_id):
applicant.user_id = applicant.job_id.user_id.id
for applicant in self:
applicant.user_id = applicant.job_id.user_id.id or self.env.uid
@api.depends('partner_id')
def _compute_partner_phone_email(self):