[FIX] base_automation: prevent automations from triggering on new records

Before this commit, automations triggering on new records caused onchanges to break out-of-context record rules, hence preventing to create the record.
This commit filters out new records from the list of records matched by the domain of an automation.

task-1998636

closes odoo/odoo#37360

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
Co-authored-by: Raphaël Collet <rco@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv)
2019-09-30 07:23:03 +00:00
committed by Damien Bouvy
co-authored by Raphaël Collet
parent ea11adf982
commit 5350c6576a
@@ -290,7 +290,7 @@ class BaseAutomation(models.Model):
if not field.store:
return _compute_field_value.origin(self, field)
actions = self.env['base.automation']._get_actions(self, ['on_write', 'on_create_or_write'])
records = self.with_env(actions.env)
records = self.filtered('id').with_env(actions.env)
# check preconditions on records
pre = {action: action._filter_pre(records) for action in actions}
# read old values before the update