Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base automation raises traceback on updates (Database fetch misses ids) #60273

Open
mchristoph opened this issue Oct 19, 2020 · 0 comments
Open
Labels
14.0 Framework General frontend/backend framework issues

Comments

@mchristoph
Copy link

Impacted versions: 14.0 (Not sure about previous versions)

Steps to reproduce: (Can be reproduced in runbot)

  1. Create automated action with following data:
  • Model: Task (project.task)
  • Active: True
  • Trigger: On Update
  • Action To Do: Create Next Activity
Example image

chrome_lK8vtQp7SR

  1. Open or create a task in Project module
  2. Click Edit to modify the task
  3. Try to change or set customer (partner_id)

Current behavior: Odoo raises a traceback with following information:

Error screenshot

chrome_ZfGFbHBsmq

Expected behavior: Odoo should change the customer and execute the automated action on save.

Further Information

I tried looking into the issue myself. I can not say if this problem exists for other models too. In our case we only have this issue with project.task and Field Service Module (industry_fsm) installed.

Changing the customer triggers following method for computed fields def _compute_display_conditions_count(self) (in Odoo Enterprise > industry_fsm > project.py > project.task:97)

Inside _compute_display_conditions_count write is called which is overwritten/patched by base.automation:

def make_write():
""" Instanciate a write method that processes action rules. """
def write(self, vals, **kw):
# retrieve the action rules to possibly execute
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)
# check preconditions on records
pre = {action: action._filter_pre(records) for action in actions}
# read old values before the update
old_values = {
old_vals.pop('id'): old_vals
for old_vals in (records.read(list(vals)) if vals else [])
}
# call original method
write.origin(records, vals, **kw)
# check postconditions, and execute actions on the records that satisfy them
for action in actions.with_context(old_values=old_values):
records, domain_post = action._filter_post_export_domain(pre[action])
action._process(records, domain_post=domain_post)
return True
return write

Error is thrown because of records.read(list(vals) in line 328.

Stacktrace
write, base_automation.py:328
_compute_display_conditions_count, project.py:103
_compute_display_conditions_count, project.py:57
_compute_display_conditions_count, project_task.py:26
_compute_field_value, models.py:4020
_compute_field_value, mail_thread.py:410
_compute_field_value, base_automation.py:349
compute_value, fields.py:1112
__get__, fields.py:973
__getitem__, models.py:5621
has_changed, models.py:5999
<listcomp>, models.py:6167
onchange, models.py:6166
_call_kw_multi, api.py:383
call_kw, api.py:396
_call_kw, main.py:1351
call_kw, main.py:1359
response_wrap, http.py:530
__call__, http.py:911
checked_call, http.py:346
wrapper, model.py:94
_call_function, http.py:358
dispatch, http.py:682
_dispatch, ir_http.py:237
_dispatch, ir_http.py:512
_dispatch, ir_http.py:29
_dispatch, ir_http.py:21
_dispatch, ir_http.py:19
_dispatch, ir_http.py:181
dispatch, http.py:1464
__call__, shared_data.py:220
__call__, http.py:1262
__call__, http.py:1294
application_unproxied, wsgi_server.py:99
application, wsgi_server.py:124
app, server.py:440
execute, serving.py:294
run_wsgi, serving.py:306
handle_one_request, serving.py:364
handle, server.py:426
handle, serving.py:329
__init__, socketserver.py:720
finish_request, socketserver.py:360
process_request_thread, socketserver.py:650
run, threading.py:870
_bootstrap_inner, threading.py:926
_bootstrap, threading.py:890

I don't have a deep understanding of Odoo's internals regarding ORM, Cache and Computed Fields. It looks to me like a problem with onchange (NewId) in combination with write (in project.task > _compute_display_conditions_count) and access to database/cache (in base.automation > records.read(list(vals)) .

@Yenthe666 Yenthe666 added 14.0 Framework General frontend/backend framework issues labels Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
14.0 Framework General frontend/backend framework issues
Projects
None yet
Development

No branches or pull requests

2 participants