From 29b1ecb4164e9203ddab9643ff21afd5f5a53848 Mon Sep 17 00:00:00 2001 From: Florent de Labarre Date: Mon, 3 Jan 2022 11:47:42 +0000 Subject: [PATCH] [FIX] base_automation: impossible to execute an action with unlink - Create two record with state == 'one' and with activities - Create an automated action if state == 'two' then record.sudo().activity_ids.action_done() - Set state == 'two' in same time of two record In the loop line 261, for the first record self.action_record_id is in cache, but for the second record it is not in cache because of the unlink made by action_done(). When the orm raise during put in cache because he have no access to self. closes odoo/odoo#82574 X-original-commit: 2207d8adbd37c6758f350cced68f285f8960c3aa Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: Raphael Collet --- addons/base_automation/models/base_automation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/base_automation/models/base_automation.py b/addons/base_automation/models/base_automation.py index b4919feb7ac..1aa8b5deb6a 100644 --- a/addons/base_automation/models/base_automation.py +++ b/addons/base_automation/models/base_automation.py @@ -256,7 +256,8 @@ class BaseAutomation(models.Model): records.write(values) # execute server actions - if self.action_server_id: + action_server = self.action_server_id + if action_server: for record in records: # we process the action if any watched field has been modified if self._check_trigger_fields(record): @@ -267,7 +268,7 @@ class BaseAutomation(models.Model): 'domain_post': domain_post, } try: - self.action_server_id.sudo().with_context(**ctx).run() + action_server.sudo().with_context(**ctx).run() except Exception as e: self._add_postmortem_action(e) raise e