Fix Change Candidate _inverse_partner_email
This commit is contained in:
parent
c225eeec5d
commit
7b91e82363
|
|
@ -48,6 +48,25 @@ class HrCandidate(models.Model):
|
||||||
rec.resume_type = ''
|
rec.resume_type = ''
|
||||||
rec.resume_name = ''
|
rec.resume_name = ''
|
||||||
|
|
||||||
|
|
||||||
|
def _inverse_partner_email(self):
|
||||||
|
for candidate in self:
|
||||||
|
if not candidate.email_from:
|
||||||
|
continue
|
||||||
|
if not candidate.partner_id:
|
||||||
|
if not candidate.partner_name:
|
||||||
|
raise UserError(_('You must define a Contact Name for this candidate.'))
|
||||||
|
candidate.partner_id = self.env['res.partner'].sudo().with_context(default_lang=self.env.lang).find_or_create(candidate.email_from)
|
||||||
|
if candidate.partner_name and not candidate.sudo().partner_id.name:
|
||||||
|
candidate.sudo().partner_id.name = candidate.partner_name
|
||||||
|
if tools.email_normalize(candidate.email_from) != tools.email_normalize(candidate.sudo().partner_id.email):
|
||||||
|
# change email on a partner will trigger other heavy code, so avoid to change the email when
|
||||||
|
# it is the same. E.g. "email@example.com" vs "My Email" <email@example.com>""
|
||||||
|
candidate.sudo().partner_id.email = candidate.email_from
|
||||||
|
if candidate.partner_phone:
|
||||||
|
candidate.sudo().partner_id.phone = candidate.partner_phone
|
||||||
|
|
||||||
|
|
||||||
def action_open_applications(self):
|
def action_open_applications(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue