[FIX] hr_recruitment: separate contacts for employees

The fix introduced in odoo/odoo#114903 created another issue: changing
the work email would change the private email also, breaking the
seperation of the contacts for the employee.

The initial behavior was correct:
 - a res.partner for the work details (email, phone, etc.)
 - a res.partner (of type private) for the personal details of the
employee.

task-3284664

closes odoo/odoo#122880

X-original-commit: 290465e57dfcb8503e382a418e0ba4498ea5693b
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Kevin Baptiste
2023-05-30 14:17:04 +02:00
parent 5b206c1c57
commit 9af60a5092
3 changed files with 2 additions and 11 deletions
+1 -1
View File
@@ -229,7 +229,7 @@
class="oe_stat_button"
icon="fa-address-card-o"
type="object"
attrs="{'invisible': [('related_contacts_count', '=', 0)]}">
attrs="{'invisible': ['|', ('id', '=', False), ('related_contacts_count', '=', 0)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="related_contacts_count"/></span>
<span class="o_stat_text">Contacts</span>
@@ -540,6 +540,7 @@ class Applicant(models.Model):
if new_partner.create_date.date() == fields.Date.today():
new_partner.write({
'type': 'private',
'name': self.partner_name or self.email_from,
'phone': self.partner_phone,
'mobile': self.partner_mobile,
})
@@ -22,16 +22,6 @@ class HrEmployee(models.Model):
])
return [('id', 'in', employees.ids)]
def default_get(self, fields):
res = super().default_get(fields)
# Add the work_contact_id to prevent the creation of a second contact with
# `_inverse_work_contact_details` method of `hr.employee.base`
if 'work_contact_id' in fields:
current_applicant = self.env['hr.applicant'].browse(self.env.context.get('default_applicant_id'))
if current_applicant:
res['work_contact_id'] = current_applicant.partner_id.id
return res
@api.model_create_multi
def create(self, vals_list):
employees = super().create(vals_list)