[FIX] mail: only generate one next activity when setting automated actions at record update

Create an automated action to create a new activity on update of a record
(e.g. a CRM lead).
At update, many fields recompute may be triggered, triggering as many write.
Thus it would generate many activities.
We simply do nothing if we are in a recompute.

Coauthored by rco

opw 1904156

closes odoo/odoo#28498
This commit is contained in:
len-odoo
2018-11-08 10:40:58 +00:00
parent 9799dd294d
commit d60f2ab0e2
+11
View File
@@ -94,6 +94,17 @@ class ServerActions(models.Model):
return False
records = self.env[action.model_id.model].browse(self._context.get('active_ids', self._context.get('active_id')))
old_values = action._context.get('old_values')
if old_values:
field_names = list(old_values[records[0].id])
field = records._fields[field_names[0]]
# Pick an arbitrary field; if it is marked to be recomputed,
# it means we are in an extraneous write triggered by the recompute.
# In this case, we should not create a new activity.
if records._recompute_check(field):
return False
vals = {
'summary': action.activity_summary or '',
'note': action.activity_note or '',