[FIX] base_automation: traceback on updates

Steps to reproduce the bug:

1.Create an automated action with the following:
   - Model: Task (project.task)
   - Active: True
   - Trigger: On Update
   - Action To Do: Create Next Activity

2. Open or create a task in Project module
3. Edit
4. Change or set customer (partner_id)

Bug:

An error message was raised.

opw:2376492

closes odoo/odoo#61812

X-original-commit: b3415d9dd0bcc1053e47b8a0082c772ca4a8220f
Related: odoo/enterprise#14772
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Goffin Simon
2020-11-17 07:50:13 +00:00
parent 76a969e1fd
commit 440e892ed7
@@ -322,7 +322,7 @@ class BaseAutomation(models.Model):
actions = self.env['base.automation']._get_actions(self, ['on_write', 'on_create_or_write'])
if not (actions and self):
return write.origin(self, vals, **kw)
records = self.with_env(actions.env)
records = self.with_env(actions.env).filtered('id')
# check preconditions on records
pre = {action: action._filter_pre(records) for action in actions}
# read old values before the update