Repository navigation
[FIX] integration_queue_job: repoint default_env to superuser in runjob - #13
Open
o-diatlenko wants to merge 1 commit into
Open
o-diatlenko wants to merge 1 commit into
o-diatlenko wants to merge 1 commit into
Conversation
runjob is auth="none", so _auth_method_none pins transaction.default_env to a uid=None env. env = http.request.env(user=SUPERUSER_ID) only builds a local env, so every mid-job flush (flushing cr.savepoint(), cr.commit()) recomputes stored fields with an empty env.user and env.company.id=False. Seen as 'operator does not exist: integer = boolean' in the account_followup query during Shopify order import (product-import savepoint). Port of OCA/queue#923 (415420f), incl. its HTTP regression test, selecting the database via the X-Odoo-Database header like the jobrunner does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/queue_job/runjobis declaredauth="none". In Odoo 19,_auth_method_nonesetstransaction.default_envto an environment withuid=None. The controller then doeswhich only builds a local environment, so
transaction.default_envkeeps no user. The job itself runs with its own user and company. But every flush that goes throughTransaction.flush(), meaning every flushingcr.savepoint()andcr.commit()inside the job, recomputes stored fields through thatuid=Noneenvironment, with an emptyenv.userandenv.company.id == False.This broke Shopify order imports for us (
integration_queue_job19.0.1.0.9 / 19.0.1.0.10).create_order_from_inputhits an unmapped product, and_import_external_productopens acr.savepoint(). The pendingsale.orderrecompute then runs in that environment, andaccount_followupbuilds its query withcompany_id=False:OCA
queue_jobhad the same bug, where it showed up in Enterprise core asaccount_accountant._compute_signing_userraising "Expected singleton: res.users()": OCA/queue#922.Fix
Same as the upstream OCA fix (OCA/queue#923, commit 415420f):
Test
tests/test_run_job_controller_http.pyis adapted from the OCA test. It calls the real/queue_job/runjobroute with theX-Odoo-Databaseheader the jobrunner sends, and checkstransaction.default_envwhen the job would be performed._try_perform_jobis patched, so nothing gets committed.AssertionError: None != 1, sodefault_envhas no user during the job)The
20.0branch has the same line inrunjoband probably needs the same change.