Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^base_import_async/|
^queue_job_batch/|
^queue_job_cron/|
^queue_job_cron_jobrunner/|
^queue_job_subscribe/|
^test_queue_job_batch/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
Expand Down
20 changes: 14 additions & 6 deletions queue_job_batch/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============
Job Queue Batch
===============
Expand All @@ -13,17 +17,17 @@ Job Queue Batch
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github
:target: https://github.com/OCA/queue/tree/18.0/queue_job_batch
:target: https://github.com/OCA/queue/tree/19.0/queue_job_batch
:alt: OCA/queue
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job_batch
:target: https://translation.odoo-community.org/projects/queue-19-0/queue-19-0-queue_job_batch
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=18.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -82,7 +86,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/queue/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/queue/issues/new?body=module:%20queue_job_batch%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/queue/issues/new?body=module:%20queue_job_batch%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -113,6 +117,10 @@ Contributors
- Maksym Yankin <maksym.yankin@camptocamp.com>
- Iván Todorovich <ivan.todorovich@camptocamp.com>

- `NextPro <https://www.nextpro.pe>`__:

- Victor Pincay <desarrollo@nextpro.pe>

Other credits
-------------

Expand All @@ -132,6 +140,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/queue <https://github.com/OCA/queue/tree/18.0/queue_job_batch>`_ project on GitHub.
This module is part of the `OCA/queue <https://github.com/OCA/queue/tree/19.0/queue_job_batch>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
7 changes: 3 additions & 4 deletions queue_job_batch/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Job Queue Batch",
"version": "18.0.1.0.0",
"version": "19.0.1.0.0",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "AGPL-3",
Expand All @@ -29,7 +29,6 @@
"queue_job_batch/static/src/**/*.xml",
"queue_job_batch/static/src/**/*.scss",
],
'installable': False,
},
'installable': False,
},
"installable": True,
}
16 changes: 8 additions & 8 deletions queue_job_batch/controllers/webclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
from odoo.http import request

from odoo.addons.mail.controllers.webclient import WebclientController
from odoo.addons.mail.tools.discuss import Store


class WebClient(WebclientController):
def _process_request_for_internal_user(self, store, **kwargs):
res = super()._process_request_for_internal_user(store, **kwargs)
if kwargs.get("systray_get_queue_job_batches"):
@classmethod
def _process_request_for_internal_user(self, store: Store, name, params):
res = super()._process_request_for_internal_user(store, name, params)
if name == "systray_get_queue_job_batches":
# sudo: bus.bus: reading non-sensitive last id
bus_last_id = request.env["bus.bus"].sudo()._bus_last_id()
batches = request.env.user._get_queue_job_batches()
store.add(batches)
store.add(
{
"queueJobBatchCounter": len(batches),
"queueJobBatchCounterBusId": bus_last_id,
}
store.add_global_values(
queueJobBatchCounter=len(batches),
queueJobBatchCounterBusId=bus_last_id,
)
return res
15 changes: 3 additions & 12 deletions queue_job_batch/models/queue_job_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from odoo import api, fields, models

from odoo.addons.mail.tools.discuss import Store


class QueueJobBatch(models.Model):
_name = "queue.job.batch"
Expand Down Expand Up @@ -109,20 +107,13 @@ def _compute_job_count(self):
rec.completeness = rec.finished_job_count / max(1, rec.job_count)
rec.failed_percentage = rec.failed_job_count / max(1, rec.job_count)

@api.model
def _to_store_fnames(self):
return (
def _to_store_defaults(self, target):
return [
"name",
"state",
"job_count",
"finished_job_count",
"failed_job_count",
"completeness",
"failed_percentage",
)

def _to_store(self, store: Store):
fnames = self._to_store_fnames()
for rec in self:
data = rec.read(fnames)[0]
store.add(rec, data)
]
13 changes: 6 additions & 7 deletions queue_job_batch/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Copyright 2025 Camptocamp SA (https://www.camptocamp.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models
from odoo import api, models


class Users(models.Model):
_name = "res.users"
_inherit = ["res.users"]

@api.model
def _init_store_data(self, store):
res = super()._init_store_data(store)
store.add(
{
"hasQueueJobBatchUserGroup": self.env.user.has_group(
"queue_job_batch.group_queue_job_batch_user"
),
}
store.add_global_values(
hasQueueJobBatchUserGroup=self.env.user.has_group(
"queue_job_batch.group_queue_job_batch_user"
),
)
return res

Expand Down
3 changes: 3 additions & 0 deletions queue_job_batch/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
- [Camptocamp](https://camptocamp.com):
- Maksym Yankin \<<maksym.yankin@camptocamp.com>\>
- Iván Todorovich \<<ivan.todorovich@camptocamp.com>\>

- [NextPro](https://www.nextpro.pe):
- Victor Pincay \<<desarrollo@nextpro.pe>\>
2 changes: 1 addition & 1 deletion queue_job_batch/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<data>
<record id="group_queue_job_batch_user" model="res.groups">
<field name="name">Job Queue Batch User</field>
<field name="category_id" ref="queue_job.module_category_queue_job" />
<field name="privilege_id" ref="queue_job.privilege_queue_job" />
</record>
<record id="queue_job.group_queue_job_manager" model="res.groups">
<field
Expand Down
46 changes: 28 additions & 18 deletions queue_job_batch/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Job Queue Batch</title>
<title>README.rst</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,36 +360,41 @@
</style>
</head>
<body>
<div class="document" id="job-queue-batch">
<h1 class="title">Job Queue Batch</h1>
<div class="document">


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="job-queue-batch">
<h1>Job Queue Batch</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b6e605728ea05be0bf98dbe6e94c197bab21882e965286ef214f719e252b444e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job_batch"><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_batch"><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>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/19.0/queue_job_batch"><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-19-0/queue-19-0-queue_job_batch"><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=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon adds an a grouper for queue jobs.</p>
<p>It allows to show your jobs in a batched form in order to know better
the results.</p>
<p>Example:</p>
<pre class="code python literal-block">
<span class="kn">from</span> <span class="nn">odoo</span> <span class="kn">import</span> <span class="n">models</span><span class="p">,</span> <span class="n">fields</span><span class="p">,</span> <span class="n">api</span><span class="w">
<span class="kn">from</span><span class="w"> </span><span class="nn">odoo</span><span class="w"> </span><span class="kn">import</span> <span class="n">models</span><span class="p">,</span> <span class="n">fields</span><span class="p">,</span> <span class="n">api</span><span class="w">


</span><span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
</span><span class="k">class</span><span class="w"> </span><span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
</span> <span class="n">_name</span> <span class="o">=</span> <span class="s1">'my.model'</span><span class="w">

</span> <span class="k">def</span> <span class="nf">my_method</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span><span class="w">
</span> <span class="k">def</span><span class="w"> </span><span class="nf">my_method</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">k</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span><span class="w">
</span> <span class="n">_logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">'executed with a: </span><span class="si">%s</span><span class="s1"> and k: </span><span class="si">%s</span><span class="s1">'</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span><span class="w">


</span><span class="k">class</span> <span class="nc">MyOtherModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
</span><span class="k">class</span><span class="w"> </span><span class="nc">MyOtherModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
</span> <span class="n">_name</span> <span class="o">=</span> <span class="s1">'my.other.model'</span><span class="w">

</span> <span class="nd">&#64;api</span><span class="o">.</span><span class="n">multi</span><span class="w">
</span> <span class="k">def</span> <span class="nf">button_do_stuff</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span><span class="w">
</span> <span class="k">def</span><span class="w"> </span><span class="nf">button_do_stuff</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span><span class="w">
</span> <span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="p">[</span><span class="s1">'queue.job.batch'</span><span class="p">]</span><span class="o">.</span><span class="n">get_new_batch</span><span class="p">(</span><span class="s1">'Group'</span><span class="p">)</span><span class="w">
</span> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">env</span><span class="p">[</span><span class="s1">'my.model'</span><span class="p">]</span><span class="o">.</span><span class="n">with_context</span><span class="p">(</span><span class="n">job_batch</span><span class="o">=</span><span class="n">batch</span><span class="p">)</span><span class="w">
</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">100</span><span class="p">):</span><span class="w">
Expand All @@ -415,29 +420,29 @@ <h1 class="title">Job Queue Batch</h1>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<p>You can manage your batch jobs from the Systray. A new button will be
shown with your currently executing job batches and the recently
finished job groups.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/queue/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/queue/issues/new?body=module:%20queue_job_batch%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/queue/issues/new?body=module:%20queue_job_batch%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<ul class="simple">
<li>Creu Blanca</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<ul class="simple">
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
Expand All @@ -454,26 +459,31 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;camptocamp.com">ivan.todorovich&#64;camptocamp.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.nextpro.pe">NextPro</a>:<ul>
<li>Victor Pincay &lt;<a class="reference external" href="mailto:desarrollo&#64;nextpro.pe">desarrollo&#64;nextpro.pe</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<h3><a class="toc-backref" href="#toc-entry-6">Other credits</a></h3>
<p>The migration of this module from 12.0 to 14.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/queue/tree/18.0/queue_job_batch">OCA/queue</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/queue/tree/19.0/queue_job_batch">OCA/queue</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</div>
</body>
</html>
16 changes: 10 additions & 6 deletions queue_job_batch/static/src/Store.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ patch(Store.prototype, {
queueJobBatchCounterBusId: 0,
queueJobBatchCounter: 0,

/** @override */
get initMessagingParams() {
return {
...super.initMessagingParams,
systray_get_queue_job_batches: true,
};
/**
* @override
* The counter has to be known before the systray menu is opened, so it is
* requested along with the rest of the initial store data.
*/
async initialize() {
await Promise.all([
this.fetchStoreData("systray_get_queue_job_batches"),
super.initialize(...arguments),
]);
},
});
Loading
Loading