summaryrefslogtreecommitdiff
path: root/addons/hr_recruitment
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2020-04-16 13:35:57 +0000
committerThibault Delavallée <tde@odoo.com>2020-04-17 06:51:46 +0000
commit7cfd364db54e88970ef51c798df3bd4df44222b3 (patch)
tree9ee4b25b2f3e708428acc0dff1cbf9a65165ae9e /addons/hr_recruitment
parent4b3589359bd5bace5035eeeb6fd04ed29075cb1e (diff)
[REF] mail, various: clean usage of mail alias
Clean the usage of mail aliases and more specifically its associated mixin `mail.alias.mixin` . Stop using context for model of aliases, and correctly give model_id and parent_model_id to the call chain through a cleaned code easier to override. We also merge methods get_alias_model_name and get_alias_values in single one called before record creation (alias first values) and right after (to have values depending on actual record). LINKS Task ID 1919277 Community PR odoo/odoo#41160 Enterprise PR odoo/enterprise#6983 Upgrade PR odoo/upgrade#872 Co-Authored-By: Rémy Voet <ryv@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/hr_recruitment')
-rw-r--r--addons/hr_recruitment/models/hr_job.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/addons/hr_recruitment/models/hr_job.py b/addons/hr_recruitment/models/hr_job.py
index 7fb74433099..5b7efdc78c8 100644
--- a/addons/hr_recruitment/models/hr_job.py
+++ b/addons/hr_recruitment/models/hr_job.py
@@ -1,5 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+import ast
+
from odoo import api, fields, models, _
@@ -91,16 +93,16 @@ class Job(models.Model):
[("job_id", "=", job.id), ("stage_id", "=", job._get_first_stage().id)]
)
- def get_alias_model_name(self, vals):
- return 'hr.applicant'
-
- def get_alias_values(self):
- values = super(Job, self).get_alias_values()
- values['alias_defaults'] = {
- 'job_id': self.id,
- 'department_id': self.department_id.id,
- 'company_id': self.department_id.company_id.id if self.department_id else self.company_id.id
- }
+ def _alias_get_creation_values(self):
+ values = super(Job, self)._alias_get_creation_values()
+ values['alias_model_id'] = self.env['ir.model']._get('hr.applicant').id
+ if self.id:
+ values['alias_defaults'] = defaults = ast.literal_eval(self.alias_defaults or "{}")
+ defaults.update({
+ 'job_id': self.id,
+ 'department_id': self.department_id.id,
+ 'company_id': self.department_id.company_id.id if self.department_id else self.company_id.id,
+ })
return values
@api.model