Skip to content

Commit 1bde09a

Browse files
committed
pre-commit run -a
1 parent 419ed27 commit 1bde09a

2 files changed

Lines changed: 102 additions & 53 deletions

File tree

queue_job/README.rst

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
=========
62
Job Queue
73
=========
@@ -17,7 +13,7 @@ Job Queue
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Mature
20-
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2218
:alt: License: LGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github
@@ -85,6 +81,36 @@ Features:
8581
.. contents::
8682
:local:
8783

84+
Use Cases / Context
85+
===================
86+
87+
Odoo treats task synchronously, like when you import a list of products
88+
it will treat each line in one big task. "Queue job" gives you the
89+
ability to detail big tasks in many smaller ones.
90+
91+
Imagine you have a lot of data to change for thousand orders, you can do
92+
it in one step and cause a heavy load on the server, and this may affect
93+
the performance of Odoo. With queue_job you can divide the work in jobs
94+
and run thousand jobs (one job for each orders). An other benefit is if
95+
one line failed it doesn't block the processing of the others, as the
96+
jobs are independent. Plus you can schedule the jobs and set a number of
97+
retries.
98+
99+
Here are some community usage examples:
100+
101+
- Mass sending invoices:
102+
`account_invoice_mass_sending <https://github.com/OCA/account-invoicing/tree/17.0/account_invoice_mass_sending>`__
103+
- Import data in the background:
104+
`base_import_async <https://github.com/OCA/queue/tree/17.0/base_import_async>`__
105+
- Export data in the background:
106+
`base_export_async <https://github.com/OCA/queue/tree/17.0/base_export_async>`__
107+
- Generate contract invoices with jobs:
108+
`contract_queue_job <https://github.com/OCA/contract/tree/17.0/contract_queue_job>`__
109+
- Generate partner invoices with
110+
jobs:`partner_invoicing_mode <https://github.com/OCA/account-invoicing/tree/17.0/partner_invoicing_mode>`__
111+
- Process the Sales Automatic Workflow actions with jobs:
112+
`sale_automatic_workflow_job <https://github.com/OCA/sale-workflow/tree/17.0/sale_automatic_workflow_job>`__
113+
88114
Installation
89115
============
90116

queue_job/static/description/index.html

Lines changed: 71 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Job Queue</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="job-queue">
364+
<h1 class="title">Job Queue</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="job-queue">
370-
<h1>Job Queue</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:0b61ae169205114262bbac28e15c8729ea4056e5f2d2c08e8f38adbe479da264
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job"><img alt="OCA/queue" src="https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/queue&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job"><img alt="OCA/queue" src="https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/queue&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This addon adds an integrated Job Queue to Odoo.</p>
379374
<p>It allows to postpone method calls executed asynchronously.</p>
380375
<p>Jobs are executed in the background by a <tt class="docutils literal">Jobrunner</tt>, in their own
@@ -420,41 +415,70 @@ <h1>Job Queue</h1>
420415
<p><strong>Table of contents</strong></p>
421416
<div class="contents local topic" id="contents">
422417
<ul class="simple">
423-
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
424-
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
425-
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a><ul>
426-
<li><a class="reference internal" href="#developers" id="toc-entry-4">Developers</a><ul>
427-
<li><a class="reference internal" href="#delaying-jobs" id="toc-entry-5">Delaying jobs</a></li>
428-
<li><a class="reference internal" href="#enqueing-job-options" id="toc-entry-6">Enqueing Job Options</a></li>
429-
<li><a class="reference internal" href="#configure-default-options-for-jobs" id="toc-entry-7">Configure default options for jobs</a></li>
430-
<li><a class="reference internal" href="#testing" id="toc-entry-8">Testing</a></li>
431-
<li><a class="reference internal" href="#tips-and-tricks" id="toc-entry-9">Tips and tricks</a></li>
432-
<li><a class="reference internal" href="#patterns" id="toc-entry-10">Patterns</a></li>
418+
<li><a class="reference internal" href="#use-cases-context" id="toc-entry-1">Use Cases / Context</a></li>
419+
<li><a class="reference internal" href="#installation" id="toc-entry-2">Installation</a></li>
420+
<li><a class="reference internal" href="#configuration" id="toc-entry-3">Configuration</a></li>
421+
<li><a class="reference internal" href="#usage" id="toc-entry-4">Usage</a><ul>
422+
<li><a class="reference internal" href="#developers" id="toc-entry-5">Developers</a><ul>
423+
<li><a class="reference internal" href="#delaying-jobs" id="toc-entry-6">Delaying jobs</a></li>
424+
<li><a class="reference internal" href="#enqueing-job-options" id="toc-entry-7">Enqueing Job Options</a></li>
425+
<li><a class="reference internal" href="#configure-default-options-for-jobs" id="toc-entry-8">Configure default options for jobs</a></li>
426+
<li><a class="reference internal" href="#testing" id="toc-entry-9">Testing</a></li>
427+
<li><a class="reference internal" href="#tips-and-tricks" id="toc-entry-10">Tips and tricks</a></li>
428+
<li><a class="reference internal" href="#patterns" id="toc-entry-11">Patterns</a></li>
433429
</ul>
434430
</li>
435431
</ul>
436432
</li>
437-
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-11">Known issues / Roadmap</a></li>
438-
<li><a class="reference internal" href="#changelog" id="toc-entry-12">Changelog</a><ul>
439-
<li><a class="reference internal" href="#next" id="toc-entry-13">Next</a></li>
433+
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-12">Known issues / Roadmap</a></li>
434+
<li><a class="reference internal" href="#changelog" id="toc-entry-13">Changelog</a><ul>
435+
<li><a class="reference internal" href="#next" id="toc-entry-14">Next</a></li>
440436
</ul>
441437
</li>
442-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-14">Bug Tracker</a></li>
443-
<li><a class="reference internal" href="#credits" id="toc-entry-15">Credits</a><ul>
444-
<li><a class="reference internal" href="#authors" id="toc-entry-16">Authors</a></li>
445-
<li><a class="reference internal" href="#contributors" id="toc-entry-17">Contributors</a></li>
446-
<li><a class="reference internal" href="#other-credits" id="toc-entry-18">Other credits</a></li>
447-
<li><a class="reference internal" href="#maintainers" id="toc-entry-19">Maintainers</a></li>
438+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-15">Bug Tracker</a></li>
439+
<li><a class="reference internal" href="#credits" id="toc-entry-16">Credits</a><ul>
440+
<li><a class="reference internal" href="#authors" id="toc-entry-17">Authors</a></li>
441+
<li><a class="reference internal" href="#contributors" id="toc-entry-18">Contributors</a></li>
442+
<li><a class="reference internal" href="#other-credits" id="toc-entry-19">Other credits</a></li>
443+
<li><a class="reference internal" href="#maintainers" id="toc-entry-20">Maintainers</a></li>
448444
</ul>
449445
</li>
450446
</ul>
451447
</div>
448+
<div class="section" id="use-cases-context">
449+
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
450+
<p>Odoo treats task synchronously, like when you import a list of products
451+
it will treat each line in one big task. “Queue job” gives you the
452+
ability to detail big tasks in many smaller ones.</p>
453+
<p>Imagine you have a lot of data to change for thousand orders, you can do
454+
it in one step and cause a heavy load on the server, and this may affect
455+
the performance of Odoo. With queue_job you can divide the work in jobs
456+
and run thousand jobs (one job for each orders). An other benefit is if
457+
one line failed it doesn’t block the processing of the others, as the
458+
jobs are independent. Plus you can schedule the jobs and set a number of
459+
retries.</p>
460+
<p>Here are some community usage examples:</p>
461+
<ul class="simple">
462+
<li>Mass sending invoices:
463+
<a class="reference external" href="https://github.com/OCA/account-invoicing/tree/17.0/account_invoice_mass_sending">account_invoice_mass_sending</a></li>
464+
<li>Import data in the background:
465+
<a class="reference external" href="https://github.com/OCA/queue/tree/17.0/base_import_async">base_import_async</a></li>
466+
<li>Export data in the background:
467+
<a class="reference external" href="https://github.com/OCA/queue/tree/17.0/base_export_async">base_export_async</a></li>
468+
<li>Generate contract invoices with jobs:
469+
<a class="reference external" href="https://github.com/OCA/contract/tree/17.0/contract_queue_job">contract_queue_job</a></li>
470+
<li>Generate partner invoices with
471+
jobs:<a class="reference external" href="https://github.com/OCA/account-invoicing/tree/17.0/partner_invoicing_mode">partner_invoicing_mode</a></li>
472+
<li>Process the Sales Automatic Workflow actions with jobs:
473+
<a class="reference external" href="https://github.com/OCA/sale-workflow/tree/17.0/sale_automatic_workflow_job">sale_automatic_workflow_job</a></li>
474+
</ul>
475+
</div>
452476
<div class="section" id="installation">
453-
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
477+
<h1><a class="toc-backref" href="#toc-entry-2">Installation</a></h1>
454478
<p>Be sure to have the <tt class="docutils literal">requests</tt> library.</p>
455479
</div>
456480
<div class="section" id="configuration">
457-
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
481+
<h1><a class="toc-backref" href="#toc-entry-3">Configuration</a></h1>
458482
<ul class="simple">
459483
<li>Using environment variables and command line:<ul>
460484
<li>Adjust environment variables (optional):<ul>
@@ -517,15 +541,15 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
517541
</table>
518542
</div>
519543
<div class="section" id="usage">
520-
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
544+
<h1><a class="toc-backref" href="#toc-entry-4">Usage</a></h1>
521545
<p>To use this module, you need to:</p>
522546
<ol class="arabic simple">
523547
<li>Go to <tt class="docutils literal">Job Queue</tt> menu</li>
524548
</ol>
525549
<div class="section" id="developers">
526-
<h3><a class="toc-backref" href="#toc-entry-4">Developers</a></h3>
550+
<h2><a class="toc-backref" href="#toc-entry-5">Developers</a></h2>
527551
<div class="section" id="delaying-jobs">
528-
<h4><a class="toc-backref" href="#toc-entry-5">Delaying jobs</a></h4>
552+
<h3><a class="toc-backref" href="#toc-entry-6">Delaying jobs</a></h3>
529553
<p>The fast way to enqueue a job for a method is to use <tt class="docutils literal">with_delay()</tt> on
530554
a record or model:</p>
531555
<pre class="code python literal-block">
@@ -645,7 +669,7 @@ <h4><a class="toc-backref" href="#toc-entry-5">Delaying jobs</a></h4>
645669
</pre>
646670
</div>
647671
<div class="section" id="enqueing-job-options">
648-
<h4><a class="toc-backref" href="#toc-entry-6">Enqueing Job Options</a></h4>
672+
<h3><a class="toc-backref" href="#toc-entry-7">Enqueing Job Options</a></h3>
649673
<ul class="simple">
650674
<li>priority: default is 10, the closest it is to 0, the faster it will be
651675
executed</li>
@@ -664,7 +688,7 @@ <h4><a class="toc-backref" href="#toc-entry-6">Enqueing Job Options</a></h4>
664688
</ul>
665689
</div>
666690
<div class="section" id="configure-default-options-for-jobs">
667-
<h4><a class="toc-backref" href="#toc-entry-7">Configure default options for jobs</a></h4>
691+
<h3><a class="toc-backref" href="#toc-entry-8">Configure default options for jobs</a></h3>
668692
<p>In earlier versions, jobs could be configured using the <tt class="docutils literal">&#64;job</tt>
669693
decorator. This is now obsolete, they can be configured using optional
670694
<tt class="docutils literal">queue.job.function</tt> and <tt class="docutils literal">queue.job.channel</tt> XML records.</p>
@@ -792,7 +816,7 @@ <h4><a class="toc-backref" href="#toc-entry-7">Configure default options for job
792816
delaying any jobs.</p>
793817
</div>
794818
<div class="section" id="testing">
795-
<h4><a class="toc-backref" href="#toc-entry-8">Testing</a></h4>
819+
<h3><a class="toc-backref" href="#toc-entry-9">Testing</a></h3>
796820
<p><strong>Asserting enqueued jobs</strong></p>
797821
<p>The recommended way to test jobs, rather than running them directly and
798822
synchronously is to split the tests in two parts:</p>
@@ -907,7 +931,7 @@ <h4><a class="toc-backref" href="#toc-entry-8">Testing</a></h4>
907931
synchronously</p>
908932
</div>
909933
<div class="section" id="tips-and-tricks">
910-
<h4><a class="toc-backref" href="#toc-entry-9">Tips and tricks</a></h4>
934+
<h3><a class="toc-backref" href="#toc-entry-10">Tips and tricks</a></h3>
911935
<ul class="simple">
912936
<li><strong>Idempotency</strong>
913937
(<a class="reference external" href="https://www.restapitutorial.com/lessons/idempotency.html">https://www.restapitutorial.com/lessons/idempotency.html</a>): The
@@ -920,7 +944,7 @@ <h4><a class="toc-backref" href="#toc-entry-9">Tips and tricks</a></h4>
920944
</ul>
921945
</div>
922946
<div class="section" id="patterns">
923-
<h4><a class="toc-backref" href="#toc-entry-10">Patterns</a></h4>
947+
<h3><a class="toc-backref" href="#toc-entry-11">Patterns</a></h3>
924948
<p>Through the time, two main patterns emerged:</p>
925949
<ol class="arabic simple">
926950
<li>For data exposed to users, a model should store the data and the
@@ -934,16 +958,16 @@ <h4><a class="toc-backref" href="#toc-entry-10">Patterns</a></h4>
934958
</div>
935959
</div>
936960
<div class="section" id="known-issues-roadmap">
937-
<h2><a class="toc-backref" href="#toc-entry-11">Known issues / Roadmap</a></h2>
961+
<h1><a class="toc-backref" href="#toc-entry-12">Known issues / Roadmap</a></h1>
938962
<ul class="simple">
939963
<li>After creating a new database or installing <tt class="docutils literal">queue_job</tt> on an
940964
existing database, Odoo must be restarted for the runner to detect it.</li>
941965
</ul>
942966
</div>
943967
<div class="section" id="changelog">
944-
<h2><a class="toc-backref" href="#toc-entry-12">Changelog</a></h2>
968+
<h1><a class="toc-backref" href="#toc-entry-13">Changelog</a></h1>
945969
<div class="section" id="next">
946-
<h3><a class="toc-backref" href="#toc-entry-13">Next</a></h3>
970+
<h2><a class="toc-backref" href="#toc-entry-14">Next</a></h2>
947971
<ul class="simple">
948972
<li>[ADD] Run jobrunner as a worker process instead of a thread in the
949973
main process (when running with –workers &gt; 0)</li>
@@ -954,24 +978,24 @@ <h3><a class="toc-backref" href="#toc-entry-13">Next</a></h3>
954978
</div>
955979
</div>
956980
<div class="section" id="bug-tracker">
957-
<h2><a class="toc-backref" href="#toc-entry-14">Bug Tracker</a></h2>
981+
<h1><a class="toc-backref" href="#toc-entry-15">Bug Tracker</a></h1>
958982
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/queue/issues">GitHub Issues</a>.
959983
In case of trouble, please check there if your issue has already been reported.
960984
If you spotted it first, help us to smash it by providing a detailed and welcomed
961985
<a class="reference external" href="https://github.com/OCA/queue/issues/new?body=module:%20queue_job%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
962986
<p>Do not contact contributors directly about support or help with technical issues.</p>
963987
</div>
964988
<div class="section" id="credits">
965-
<h2><a class="toc-backref" href="#toc-entry-15">Credits</a></h2>
989+
<h1><a class="toc-backref" href="#toc-entry-16">Credits</a></h1>
966990
<div class="section" id="authors">
967-
<h3><a class="toc-backref" href="#toc-entry-16">Authors</a></h3>
991+
<h2><a class="toc-backref" href="#toc-entry-17">Authors</a></h2>
968992
<ul class="simple">
969993
<li>Camptocamp</li>
970994
<li>ACSONE SA/NV</li>
971995
</ul>
972996
</div>
973997
<div class="section" id="contributors">
974-
<h3><a class="toc-backref" href="#toc-entry-17">Contributors</a></h3>
998+
<h2><a class="toc-backref" href="#toc-entry-18">Contributors</a></h2>
975999
<ul class="simple">
9761000
<li>Guewen Baconnier &lt;<a class="reference external" href="mailto:guewen.baconnier&#64;camptocamp.com">guewen.baconnier&#64;camptocamp.com</a>&gt;</li>
9771001
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
@@ -991,12 +1015,12 @@ <h3><a class="toc-backref" href="#toc-entry-17">Contributors</a></h3>
9911015
</ul>
9921016
</div>
9931017
<div class="section" id="other-credits">
994-
<h3><a class="toc-backref" href="#toc-entry-18">Other credits</a></h3>
1018+
<h2><a class="toc-backref" href="#toc-entry-19">Other credits</a></h2>
9951019
<p>The migration of this module from 17.0 to 18.0 was financially supported
9961020
by Camptocamp.</p>
9971021
</div>
9981022
<div class="section" id="maintainers">
999-
<h3><a class="toc-backref" href="#toc-entry-19">Maintainers</a></h3>
1023+
<h2><a class="toc-backref" href="#toc-entry-20">Maintainers</a></h2>
10001024
<p>This module is maintained by the OCA.</p>
10011025
<a class="reference external image-reference" href="https://odoo-community.org">
10021026
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -1011,6 +1035,5 @@ <h3><a class="toc-backref" href="#toc-entry-19">Maintainers</a></h3>
10111035
</div>
10121036
</div>
10131037
</div>
1014-
</div>
10151038
</body>
10161039
</html>

0 commit comments

Comments
 (0)