diff --git a/addons/hr/models/hr.py b/addons/hr/models/hr.py
index ccfe751025b..dc49f6f2022 100644
--- a/addons/hr/models/hr.py
+++ b/addons/hr/models/hr.py
@@ -112,6 +112,10 @@ class Employee(models.Model):
# private partner
address_home_id = fields.Many2one(
'res.partner', 'Private Address', help='Enter here the private address of the employee, not the one linked to your company.')
+ is_address_home_a_company = fields.Boolean(
+ 'The employee adress has a company linked',
+ compute='_compute_is_address_home_a_company',
+ )
country_id = fields.Many2one(
'res.country', 'Nationality (Country)')
gender = fields.Selection([
@@ -260,6 +264,12 @@ class Employee(models.Model):
# Do not notify user it has been marked as follower of its employee.
return
+ @api.depends('address_home_id.parent_id')
+ def _compute_is_address_home_a_company(self):
+ """Checks that choosen address (res.partner) is not linked to a company.
+ """
+ for employee in self:
+ employee.is_address_home_a_company = employee.address_home_id.parent_id.id is not False
class Department(models.Model):
_name = "hr.department"
diff --git a/addons/hr/views/hr_views.xml b/addons/hr/views/hr_views.xml
index 74a26de680c..275048127bf 100644
--- a/addons/hr/views/hr_views.xml
+++ b/addons/hr/views/hr_views.xml
@@ -87,6 +87,12 @@
+
+
+ Use here the home address of the employee.
+ This private address is used in the expense report reimbursement document.
+ It should be different from the work address.
+
diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py
index adec7b15f57..bf6a1fb8242 100644
--- a/addons/hr_recruitment/models/hr_recruitment.py
+++ b/addons/hr_recruitment/models/hr_recruitment.py
@@ -397,19 +397,32 @@ class Applicant(models.Model):
""" Create an hr.employee from the hr.applicants """
employee = False
for applicant in self:
- address_id = contact_name = False
+ contact_name = False
if applicant.partner_id:
address_id = applicant.partner_id.address_get(['contact'])['contact']
contact_name = applicant.partner_id.name_get()[0][1]
+ else :
+ new_partner_id = self.env['res.partner'].create({
+ 'is_company': False,
+ 'name': applicant.partner_name,
+ 'email': applicant.email_from,
+ 'phone': applicant.partner_phone,
+ 'mobile': applicant.partner_mobile
+ })
+ address_id = new_partner_id.address_get(['contact'])['contact']
if applicant.job_id and (applicant.partner_name or contact_name):
applicant.job_id.write({'no_of_hired_employee': applicant.job_id.no_of_hired_employee + 1})
- employee = self.env['hr.employee'].create({'name': applicant.partner_name or contact_name,
- 'job_id': applicant.job_id.id,
- 'address_home_id': address_id,
- 'department_id': applicant.department_id.id or False,
- 'address_id': applicant.company_id and applicant.company_id.partner_id and applicant.company_id.partner_id.id or False,
- 'work_email': applicant.department_id and applicant.department_id.company_id and applicant.department_id.company_id.email or False,
- 'work_phone': applicant.department_id and applicant.department_id.company_id and applicant.department_id.company_id.phone or False})
+ employee = self.env['hr.employee'].create({
+ 'name': applicant.partner_name or contact_name,
+ 'job_id': applicant.job_id.id,
+ 'address_home_id': address_id,
+ 'department_id': applicant.department_id.id or False,
+ 'address_id': applicant.company_id and applicant.company_id.partner_id
+ and applicant.company_id.partner_id.id or False,
+ 'work_email': applicant.department_id and applicant.department_id.company_id
+ and applicant.department_id.company_id.email or False,
+ 'work_phone': applicant.department_id and applicant.department_id.company_id
+ and applicant.department_id.company_id.phone or False})
applicant.write({'emp_id': employee.id})
applicant.job_id.message_post(
body=_('New Employee %s Hired') % applicant.partner_name if applicant.partner_name else applicant.name,