Skip to content

[20.0][MIG] queue_job_subscribe, test_queue_job; [IMP] queue_job: align with OCA 20.0 - #10

Merged
dhongu merged 179 commits into
20.0from
20.0-mig-lot-oca
Nov 28, 2026
Merged

dhongu merged 179 commits into
20.0from
20.0-mig-lot-oca

Conversation

@dhongu

@dhongu dhongu commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Lot OCA queue → 20.0 (branch 20.0-mig-lot-oca, merge --no-ff din 20.0-mig-queue_job_subscribe, 20.0-mig-test_queue_job, 20.0-sync-queue_job-oca).

  • queue_job 20.0.2.4.0: aliniat cu OCA/queue@20.0 (8ef3956). Fork-ul era o copie a unui OCA 19.0 mai vechi, fără commit-uri proprii pe 19.0; îi lipseau: ștergerea joburilor vechi din autovacuum-ul de bază (cu intervalul de pe canal), anularea tuturor dependenților unui job anulat (cu date_cancelled), lock-uri mai slabe, refactorizarea achiziției de joburi, header-ul X-Odoo-Database în locul patch-ului post_load pe router, testele controllerului runjob. Delta fork-ului păstrată:
    • versiunea 20.0.2.4.0 (peste 20.0.2.0.2 din fork, nu 20.0.1.0.0 ca în OCA);
    • migrations/20.0.2.4.0 șterge ir_cron_autovacuum_queue_jobs și pe bazele deja pe fork-ul 20.0 (sar pasul 19.0.2.2.0; metoda autovacuum() nu mai există).
    • Dependență nouă: openupgradelib (în requirements.txt, deja folosită în others_addons).
  • queue_job_cron_jobrunner 20.0.1.0.2: PG_CONCURRENCY_ERRORS_TO_RETRY a dispărut din controller → odoo.sql_db.PG_CONCURRENCY_EXCEPTIONS_TO_RETRY cu isinstance, ca în [20.0][MIG] queue_job_cron_jobrunner: Migration to 20.0 OCA/queue#1008; portul nostru RetryableJobError.seconds rămâne.
  • queue_job_subscribe 20.0.1.0.0: istoricul 19.0 reluat (mig_module.sh --skip-fisa, fork OCA), aliniat cu [MIG] queue_job_subscribe: Migration to 20.0 OCA/queue#1036.
  • test_queue_job 20.0.2.2.0: testele complete din [20.0][MIG] test_queue_job: Migration to 20.0 OCA/queue#1021 (pe lângă ir.access și with_company() din 20).

Dublura queue_job_subscribe din dhongu/others_addons nu se migrează: pe 20.0 suita sursă pentru queue_job* e queue (auditlog: dhongu/others_addons#12).

Teste locale (baze noi, --skip-auto-install):

  • test20_qsync_queue: queue_job 81, queue_job_cron_jobrunner 10, queue_job_subscribe 4, test_queue_job 166, auditlog 80 → 0 eșecuri, 0 WARNING;
  • test20_qsync_dt: deltatech_queue_job 50 teste, 0 eșecuri (dependent: patch pe Job.cancel_dependent_jobs, devenit redundant, dar inofensiv);
  • test20_qsync_mkt: deltatech_marketplace_queue_job 17 teste, 0 eșecuri;
  • upgrade queue_job 20.0.2.0.2 (fork vechi) → 20.0.2.4.0: migrarea rulează, cronul vechi dispare, 0 WARNING.

Preexistent, neschimbat: cu deltatech_queue_job instalat, 2 teste din queue_job_cron_jobrunner (test_queue_job_cron_trigger*) pică și pe vechiul 20.0 — deltatech_queue_job își înlocuiește _cron_trigger.

pre-commit run -a curat.

Assisted-by: Claude Opus 5.5

guewen and others added 30 commits November 28, 2026 02:53
Separate tests that need special methods in a dedicated test_queue_job
module.

Rework the registry of the jobs. The 'job' decorator is applied on
functions before they are bound to their class, so we don't know the
class yet. Now, the decorator marks job methods with 'delayable' and
when a model is registered (Base._register_hook), it looks for the
marked methods and register them.
To avoid to pollute 'queue.job.function' with a test job.
The model name, method name, recordset ids, arguments and keyword
arguments must never ever be modified after the creation of a job.
This change fix a bug when a job with a mutable argument see the content
of the argument being modified during the execution of a job.
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
The related action button now opens by default the record on which the
job is working. It uses the default views of the job. The exact behavior
depends of the number of records in the job:

* No record (job called on a  model): display a message indicating that
there is no available action
* One record: open the default view in form
* Several records: open the default view in list

The related action can still be overridden by the 'related_action'
decorator.
Currently translated at 100.0% (12 of 12 strings)

Translation: queue-12.0/queue-12.0-test_queue_job
Translate-URL: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-test_queue_job/zh_CN/
The former syntax is deprecated
This change has been done and accepted on the component and connector
addons: OCA/connector#356

This is a low-level technical module, we may need to use jobs on
enterprise features.
hoangtrann and others added 18 commits November 28, 2026 02:53
In this commit we cleanly separate the job acquisition (i.e. verifying the job is in the exepected state, marking it started and locking it) from job execution.

We also avoid trying to start the job if it is already locked by using SKIP LOCKED
and exiting early. Indeed in such situations the job is likely already being handled by another worker so there is no point trying to start it, so we exit early
and let it be handled either by the other worker or the dead job requeuer.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: queue-18.0/queue-18.0-queue_job_subscribe
Translate-URL: https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job_subscribe/
Since we are not going to delete records nor modify foreign keys,
we can take a weaker lock.
Every time a job is done, even if it is not part of a graph, it runs a
query to look for dependents to enqueue. Storing the dependent uuids in
the "dependencies" field was on purpose to know that we have no further
jobs in the graph and that we can skip the check entirely and have no
overhead in this case.

It looks like an oversight, we can add the missing condition.
queue_job_cron_jobrunner and queue_job_subscribe are installable on
19.0: drop them from the excluded addons and regenerate the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aligned with OCA#1036 (Command.link in tests).

Assisted-by: Claude Opus 5.5
ir.access; with_company() no longer sets allowed_company_ids for the
current company and keeps the other allowed companies (tests adapted as
in OCA#1021). The newer tests of OCA#1021 are not taken:
they need queue_job features the fork does not have yet.

Assisted-by: Claude Opus 5.5
Code of OCA/queue@20.0 (8ef3956): the fork was a copy of an older
OCA 19.0 and missed the later 19.0 work (old jobs removed by the base
autovacuum, per channel removal interval, cancel all dependent jobs of a
cancelled job, weaker locks, job acquisition refactor, runjob controller
tests, X-Odoo-Database header instead of the post_load router patch).

Fork deltas kept: version 20.0.2.4.0 (above the fork's 20.0.2.0.2), and
migrations/20.0.2.4.0 dropping ir_cron_autovacuum_queue_jobs for the
databases already on the fork 20.0, which skip the 19.0.2.2.0 step.

Assisted-by: Claude Opus 5.5
queue_job 20.0 no longer exposes PG_CONCURRENCY_ERRORS_TO_RETRY: retry
on the exception classes of odoo.sql_db, as in OCA#1008.

Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
With queue_job aligned on OCA/queue 20.0, take the remaining tests of
OCA#1021: autovacuum per channel and from the base autovacuum,
cancel of dependent jobs, recordset arguments rebound on commit.

Assisted-by: Claude Opus 5.5
@dhongu dhongu changed the title [20.0][MIG] queue_job_subscribe, test_queue_job: Migration to 20.0 [20.0][MIG] queue_job_subscribe, test_queue_job; [IMP] queue_job: align with OCA 20.0 Nov 28, 2026
@dhongu
dhongu marked this pull request as ready for review November 28, 2026 03:14
@dhongu
dhongu merged commit c83822c into 20.0 Nov 28, 2026
3 checks passed
@dhongu
dhongu deleted the 20.0-mig-lot-oca branch November 28, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.