From d60f2ab0e26f5918a713cbe5abfc8f20f7d8ddb1 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Thu, 8 Nov 2018 10:40:55 +0000 Subject: [PATCH] [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 --- addons/mail/models/ir_actions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/mail/models/ir_actions.py b/addons/mail/models/ir_actions.py index 6f2b6ae136a..b15b77f3ed9 100644 --- a/addons/mail/models/ir_actions.py +++ b/addons/mail/models/ir_actions.py @@ -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 '',