[FIX] mail: ir_action have a stored field containing the model name

Make a CRM lead, assign it to a portal user
Have an automated action which add followers on create and write
From the portal, edit the lead

Before this commit, it crashed because a portal user doesn't have access to ir.model
(4a18d5744e)

After this commit, the flow works, because we use the stored model name on the action
instead of trying to read ir.model

OPW 1985570

closes odoo/odoo#33211

Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Lucas Perais (lpe)
2019-05-07 09:07:20 +00:00
parent b80a6df68a
commit 9cb9e227c9
+3 -3
View File
@@ -70,7 +70,7 @@ class ServerActions(models.Model):
@api.model
def run_action_followers_multi(self, action, eval_context=None):
Model = self.env[action.model_id.model]
Model = self.env[action.model_name]
if self.partner_ids or self.channel_ids and hasattr(Model, 'message_subscribe'):
records = Model.browse(self._context.get('active_ids', self._context.get('active_id')))
records.message_subscribe(self.partner_ids.ids, self.channel_ids.ids)
@@ -83,7 +83,7 @@ class ServerActions(models.Model):
When need to know it to skip these steps.
Except if the computed field is supposed to trigger the action
"""
records = self.env[action.model_id.model].browse(
records = self.env[action.model_name].browse(
self._context.get('active_ids', self._context.get('active_id')))
old_values = action._context.get('old_values')
if old_values:
@@ -121,7 +121,7 @@ class ServerActions(models.Model):
if not action.activity_type_id or not self._context.get('active_id') or self._is_recompute(action):
return False
records = self.env[action.model_id.model].browse(self._context.get('active_ids', self._context.get('active_id')))
records = self.env[action.model_name].browse(self._context.get('active_ids', self._context.get('active_id')))
vals = {
'summary': action.activity_summary or '',