summaryrefslogtreecommitdiff
path: root/addons/project/models
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/project/models
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/project/models')
-rw-r--r--addons/project/models/project.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index 64a25144a69..ed79097320d 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -69,14 +69,6 @@ class Project(models.Model):
_rating_satisfaction_days = False # takes all existing ratings
_check_company_auto = True
- def get_alias_model_name(self, vals):
- return vals.get('alias_model', 'project.task')
-
- def get_alias_values(self):
- values = super(Project, self).get_alias_values()
- values['alias_defaults'] = {'project_id': self.id}
- return values
-
def _compute_attached_docs_count(self):
Attachment = self.env['ir.attachment']
for project in self:
@@ -401,6 +393,14 @@ class Project(models.Model):
self.mapped('tasks').message_unsubscribe(partner_ids=partner_ids, channel_ids=channel_ids)
return super(Project, self).message_unsubscribe(partner_ids=partner_ids, channel_ids=channel_ids)
+ def _alias_get_creation_values(self):
+ values = super(Project, self)._alias_get_creation_values()
+ values['alias_model_id'] = self.env['ir.model']._get('project.task').id
+ if self.id:
+ values['alias_defaults'] = defaults = ast.literal_eval(self.alias_defaults or "{}")
+ defaults['project_id'] = self.id
+ return values
+
# ---------------------------------------------------
# Actions
# ---------------------------------------------------