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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^base_import_async/|
^queue_job_batch/|
^queue_job_cron/|
^queue_job_cron_jobrunner/|
^queue_job_subscribe/|
Expand Down
16 changes: 10 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/20.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-20-0/queue-20-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=20.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:%2020.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 @@ -132,6 +136,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/20.0/queue_job_batch>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
13 changes: 6 additions & 7 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": "20.0.1.0.0",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "AGPL-3",
Expand All @@ -13,12 +13,12 @@
"queue_job",
],
"data": [
# security
"security/security.xml",
"security/ir.access.csv",
# data
"data/queue_job_channel_data.xml",
"data/queue_job_function_data.xml",
# security
"security/security.xml",
"security/ir.model.access.csv",
# views
"views/queue_job_views.xml",
"views/queue_job_batch_views.xml",
Expand All @@ -29,7 +29,6 @@
"queue_job_batch/static/src/**/*.xml",
"queue_job_batch/static/src/**/*.scss",
],
'installable': False,
},
'installable': False,
},
"installable": True,
}
26 changes: 12 additions & 14 deletions queue_job_batch/controllers/webclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
from odoo.http import request

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


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"):
# 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,
}
)
return res
@store_handler("systray_get_queue_job_batches")
def store_systray_get_queue_job_batches(self, store: Store):
# 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_queue_job_batch_fields")
store.add_global_values(
queueJobBatchCounter=len(batches),
queueJobBatchCounterBusId=bus_last_id,
)
3 changes: 2 additions & 1 deletion queue_job_batch/data/queue_job_channel_data.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record model="queue.job.channel" id="channel_queue_job_batch">
<record id="channel_queue_job_batch" model="queue.job.channel">
<field name="name">queue.job.batch</field>
<field name="parent_id" ref="queue_job.channel_root" />
</record>
Expand Down
1 change: 1 addition & 0 deletions queue_job_batch/data/queue_job_function_data.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="job_function_queue_job_check_state" model="queue.job.function">
<field name="model_id" ref="queue_job_batch.model_queue_job_batch" />
Expand Down
4 changes: 3 additions & 1 deletion queue_job_batch/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ def write(self, vals):
for batch in batches:
# We need to make it with delay in order to prevent two jobs
# to work with the same batch
batch.with_delay(identity_key=identity_exact).check_state()
batch.with_context(job_batch=False).with_delay(
identity_key=identity_exact
).check_state()
return super().write(vals)
13 changes: 5 additions & 8 deletions queue_job_batch/models/queue_job_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class QueueJobBatch(models.Model):
_name = "queue.job.batch"
_inherit = ["mail.thread", "mail.activity.mixin"]
_inherit = ["mail.thread", "mail.activity.mixin"] # noqa: RUF012
_description = "Batch of jobs"
_log_access = False

Expand Down Expand Up @@ -111,18 +111,15 @@ def _compute_job_count(self):

@api.model
def _to_store_fnames(self):
return (
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)
def _store_queue_job_batch_fields(self, res: Store.FieldList):
res.extend(self._to_store_fnames())
22 changes: 10 additions & 12 deletions queue_job_batch/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@

from odoo import models

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


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

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"
),
}
def _store_init_global_fields(self, res: Store.FieldList):
result = super()._store_init_global_fields(res)
res.attr(
"hasQueueJobBatchUserGroup",
self.env.user.has_group("queue_job_batch.group_queue_job_batch_user"),
)
return res
return result

def _get_queue_job_batches(self):
# See :meth:`controllers.webclient.WebClient._process_request_for_internal_user`
# See controllers.webclient.WebClient.store_systray_get_queue_job_batches
self.ensure_one()
return self.env["queue.job.batch"].search(
[
Expand Down
5 changes: 5 additions & 0 deletions queue_job_batch/security/ir.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name,model_id,group_id/id,operation,domain
access_queue_job_batch_user,queue job batch user,queue.job.batch,queue_job_batch.group_queue_job_batch_user,ru,"[('user_id', '=', user.id)]"
access_queue_job_batch_manager,queue job batch manager,queue.job.batch,queue_job.group_queue_job_manager,crud,
queue_job_batch_comp_rule,Job Queue batch multi-company,queue.job.batch,,crud,"['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]"
access_queue_job_queue_job_batch_user,queue job batch queue.job user,queue.job,queue_job_batch.group_queue_job_batch_user,r,
4 changes: 0 additions & 4 deletions queue_job_batch/security/ir.model.access.csv

This file was deleted.

55 changes: 11 additions & 44 deletions queue_job_batch/security/security.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<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" />
</record>
<record id="queue_job.group_queue_job_manager" model="res.groups">
<field
name="implied_ids"
eval="[(4, ref('queue_job_batch.group_queue_job_batch_user'))]"
/>
</record>
</data>

<data noupdate="1">
<record id="queue_job_batch_comp_rule" model="ir.rule">
<field name="name">Job Queue batch multi-company</field>
<field name="model_id" ref="model_queue_job_batch" />
<field name="global" eval="True" />
<field
name="domain_force"
>['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>

<record id="queue_job_batch_user_rule" model="ir.rule">
<field name="name">Job Queue batch user filter</field>
<field name="model_id" ref="model_queue_job_batch" />
<field
name="groups"
eval="[(4, ref('queue_job_batch.group_queue_job_batch_user'))]"
/>
<field name="domain_force">[('user_id', '=', user.id)]</field>
</record>

<record id="queue_job_batch_manager_rule" model="ir.rule">
<field name="name">Job Queue batch manager</field>
<field name="model_id" ref="model_queue_job_batch" />
<field
name="groups"
eval="[(4, ref('queue_job.group_queue_job_manager'))]"
/>
<field name="domain_force">[(1, '=', 1)]</field>
</record>
</data>
<record id="group_queue_job_batch_user" model="res.groups">
<field name="name">Job Queue Batch User</field>
<field name="privilege_id" ref="queue_job.privilege_queue_job" />
</record>
<record id="queue_job.group_queue_job_manager" model="res.groups">
<field
name="implied_ids"
eval="[Command.link(ref('queue_job_batch.group_queue_job_batch_user'))]"
/>
</record>
</odoo>
Loading
Loading