diff --git a/queue_job/README.rst b/queue_job/README.rst index 182fe5ea84..7940ce80dc 100644 --- a/queue_job/README.rst +++ b/queue_job/README.rst @@ -11,7 +11,7 @@ Job Queue !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:9310ffeb8c7cc9466fe499b49ab3d7f8da8bd13d2dd9a3f6cc3f3b2fa2f852e3 + !! source digest: sha256:8fe930e0d2082bf352442794a848d2931d0f853a2f5e1b0d066f10d4c68fb33f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png diff --git a/queue_job/__init__.py b/queue_job/__init__.py index 6ca18c3309..19ffa60c25 100644 --- a/queue_job/__init__.py +++ b/queue_job/__init__.py @@ -4,7 +4,6 @@ from . import wizards from . import jobrunner from .post_init_hook import post_init_hook -from .post_load import post_load # shortcuts from .job import identity_exact diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index 5669066f8f..e04b0f1be5 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,13 +2,13 @@ { "name": "Job Queue", - "version": "20.0.2.0.2", + "version": "20.0.2.4.0", "author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "LGPL-3", "category": "Generic Modules", "depends": ["mail", "base_sparse_field", "web"], - "external_dependencies": {"python": ["requests"]}, + "external_dependencies": {"python": ["requests", "openupgradelib"]}, "data": [ "security/security.xml", "security/ir.access.csv", @@ -31,5 +31,4 @@ "development_status": "Mature", "maintainers": ["guewen", "sbidoul"], "post_init_hook": "post_init_hook", - "post_load": "post_load", } diff --git a/queue_job/controllers/main.py b/queue_job/controllers/main.py index 39dc1ed20e..ef0fa0baef 100644 --- a/queue_job/controllers/main.py +++ b/queue_job/controllers/main.py @@ -13,6 +13,7 @@ from werkzeug.exceptions import BadRequest, Forbidden from odoo import SUPERUSER_ID, api, http +from odoo.sql_db import PG_CONCURRENCY_EXCEPTIONS_TO_RETRY from odoo.tools import config from ..delay import chain, group @@ -23,14 +24,6 @@ PG_RETRY = 5 # seconds -# odoo.service.model.PG_CONCURRENCY_ERRORS_TO_RETRY was removed in 20.0 -# (odoo.sql_db only exposes the exception classes now) -PG_CONCURRENCY_ERRORS_TO_RETRY = ( - errorcodes.LOCK_NOT_AVAILABLE, - errorcodes.SERIALIZATION_FAILURE, - errorcodes.DEADLOCK_DETECTED, -) - DEPENDS_MAX_TRIES_ON_CONCURRENCY_FAILURE = 5 @@ -105,10 +98,14 @@ def _try_perform_job(cls, env, job): # TODO refactor, the relation between env and job.env is not clear assert env.cr is job.env.cr with _prevent_commit(env.cr): - job.perform() - # Triggers any stored computed fields before calling 'set_done' - # so that will be part of the 'exec_time' - env.flush_all() + # On failure, rolling back the savepoint releases the row locks + # the job took on the records it updated: the failure is handled + # from another cursor, which may write on the same records (e.g. + # the on fail hook). + # On success, leaving the savepoint flushes, before 'set_done', so + # that the stored computed fields are part of the 'exec_time'. + with env.cr.savepoint(): + job.perform() job.set_done() job.store() env.flush_all() @@ -130,7 +127,7 @@ def _enqueue_dependent_jobs(cls, env, job): except OperationalError as err: # Automatically retry the typical transaction serialization # errors - if err.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY: + if not isinstance(err, PG_CONCURRENCY_EXCEPTIONS_TO_RETRY): raise if tries >= DEPENDS_MAX_TRIES_ON_CONCURRENCY_FAILURE: _logger.error( @@ -167,7 +164,7 @@ def retry_postpone(job, message, seconds=None): except OperationalError as err: # Automatically retry the typical transaction serialization # errors - if err.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY: + if not isinstance(err, PG_CONCURRENCY_EXCEPTIONS_TO_RETRY): raise _logger.debug("%s OperationalError, postponed", job) @@ -193,6 +190,7 @@ def retry_postpone(job, message, seconds=None): vals = cls._get_failure_values(job, traceback_txt, orig_exception) job.set_failed(**vals) job.store() + job.on_fail(vals) buff.close() raise @@ -220,9 +218,9 @@ def _get_failure_values(cls, job, traceback_txt, orig_exception): save_session=False, readonly=False, ) - def runjob(self, db, job_uuid, **kw): - http.request.session.db = db - env = http.request.env(user=SUPERUSER_ID) + def runjob(self, job_uuid, **kw): + http.request.update_env(user=SUPERUSER_ID) + env = http.request.env job = self._acquire_job(env, job_uuid) if not job: return "" @@ -394,6 +392,5 @@ def _create_graph_test_jobs( root_delayable.delay() - return ( - f"graph uuid: {list(root_delayable._head())[0]._generated_job.graph_uuid}" - ) + head = next(iter(root_delayable._head())) + return f"graph uuid: {head._generated_job.graph_uuid}" diff --git a/queue_job/data/queue_data.xml b/queue_job/data/queue_data.xml index 1fb70f106c..df010767b3 100644 --- a/queue_job/data/queue_data.xml +++ b/queue_job/data/queue_data.xml @@ -1,4 +1,4 @@ - + @@ -7,19 +7,9 @@ queue.job - - AutoVacuum Job Queue - - - - 1 - days - code - model.autovacuum() - - + root diff --git a/queue_job/data/queue_job_function_data.xml b/queue_job/data/queue_job_function_data.xml index 0105dbc508..31ec7ff964 100644 --- a/queue_job/data/queue_job_function_data.xml +++ b/queue_job/data/queue_job_function_data.xml @@ -1,3 +1,4 @@ + diff --git a/queue_job/delay.py b/queue_job/delay.py index 60e98dc9d6..8abc3133bc 100644 --- a/queue_job/delay.py +++ b/queue_job/delay.py @@ -58,7 +58,7 @@ class Graph: instances, although ultimately it is used for this purpose. """ - __slots__ = "_graph" + __slots__ = ("_graph",) def __init__(self, graph=None): if graph: @@ -314,7 +314,7 @@ class DelayableChain: delayable/chain/group object of the graph. """ - __slots__ = ("_graph", "__head", "__tail") + __slots__ = ("__head", "__tail", "_graph") def __init__(self, *delayables): self._graph = DelayableGraph() @@ -371,7 +371,7 @@ class DelayableGroup: delayable/chain/group object of the graph. """ - __slots__ = ("_graph", "_delayables") + __slots__ = ("_delayables", "_graph") def __init__(self, *delayables): self._graph = DelayableGraph() diff --git a/queue_job/fields.py b/queue_job/fields.py index efd405cf41..e2fcbdfe4a 100644 --- a/queue_job/fields.py +++ b/queue_job/fields.py @@ -30,7 +30,7 @@ class JobSerialized(fields.Json): _base_type = None # these are the default values when we convert an empty value - _default_json_mapping = { + _default_json_mapping = { # noqa: RUF012 dict: "{}", list: "[]", tuple: "[]", diff --git a/queue_job/i18n/de.po b/queue_job/i18n/de.po index 09c53ca4f1..49a98b7a9f 100644 --- a/queue_job/i18n/de.po +++ b/queue_job/i18n/de.po @@ -78,11 +78,6 @@ msgstr "Argumente" msgid "Attachment Count" msgstr "Anzahl der Anhänge" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "AutoVacuum für Job-Warteschlange" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -117,6 +112,12 @@ msgstr "" msgid "Cancelled" msgstr "" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -231,6 +232,16 @@ msgstr "" msgid "Dependency Graph" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -469,12 +480,22 @@ msgstr "Job ist fehlgeschlagen" msgid "Jobs" msgstr "Jobs" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -557,6 +578,12 @@ msgstr "Modell" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -615,6 +642,11 @@ msgstr "" msgid "Number of messages with delivery error" msgstr "Das ist die Anzahl von Nachrichten mit Übermittlungsfehler" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -934,6 +966,9 @@ msgstr "" msgid "id" msgstr "" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "AutoVacuum für Job-Warteschlange" + #~ msgid "Group By" #~ msgstr "Gruppieren nach" diff --git a/queue_job/i18n/es.po b/queue_job/i18n/es.po index 060779f8a1..a2ff33074f 100644 --- a/queue_job/i18n/es.po +++ b/queue_job/i18n/es.po @@ -81,11 +81,6 @@ msgstr "Argumentos" msgid "Attachment Count" msgstr "Nº de archivos adjuntos" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "Vaciado automático de la cola de trabajos" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -120,6 +115,12 @@ msgstr "Cancelar trabajos" msgid "Cancelled" msgstr "Cancelada" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -234,6 +235,16 @@ msgstr "Dependencias" msgid "Dependency Graph" msgstr "Gráfico de dependencias" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -470,12 +481,22 @@ msgstr "Trabajo fallido" msgid "Jobs" msgstr "Trabajos" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "Trabajos para gráfico %s" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -558,6 +579,12 @@ msgstr "Modelo" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -616,6 +643,11 @@ msgstr "Número de mensajes que requieren una acción" msgid "Number of messages with delivery error" msgstr "Número de mensajes con error de envío" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -946,6 +978,9 @@ msgstr "Pid del trabajador" msgid "id" msgstr "" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "Vaciado automático de la cola de trabajos" + #~ msgid "Group By" #~ msgstr "Agrupar por" diff --git a/queue_job/i18n/fa.po b/queue_job/i18n/fa.po new file mode 100644 index 0000000000..707e59ad93 --- /dev/null +++ b/queue_job/i18n/fa.po @@ -0,0 +1,952 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-08-12 04:46+0000\n" +"Last-Translator: Mostafa Barmshory \n" +"Language-Team: none\n" +"Language: fa\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "" +"
\n" +" If the max. " +"retries is 0, the number of retries is infinite." +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/controllers/main.py:0 +msgid "Access Denied" +msgstr "دسترسی غیر مجاز" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_needaction +msgid "Action Needed" +msgstr "نیاز به اقدام" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_ids +msgid "Activities" +msgstr "فعالیت‌ها" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_exception_decoration +msgid "Activity Exception Decoration" +msgstr "دکوراسیون فعالیت خطا" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_state +msgid "Activity State" +msgstr "وضعیت فعالیت" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_type_icon +msgid "Activity Type Icon" +msgstr "ایکن وضعیت فعالیت" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit +msgid "Allow Commit" +msgstr "اجازه کامیت" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit +msgid "" +"Allows the job to commit transactions during execution. Under the hood, this " +"executes the job in a new database cursor, which incurs an overhead as it " +"requires an extra connection to the database. " +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__args +msgid "Args" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_attachment_count +msgid "Attachment Count" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_base +msgid "Base" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_requeue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_cancelled +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_done +msgid "Cancel" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_jobs_to_cancelled +msgid "Cancel all selected jobs" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Cancel job" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_set_jobs_cancelled +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_cancelled +msgid "Cancel jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__cancelled +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Cancelled" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Cancelled by %s" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_channel.py:0 +msgid "Cannot change the root channel" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_channel.py:0 +msgid "Cannot remove the root channel" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__channel +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__channel_id +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_function_search +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Channel" +msgstr "" + +#. module: queue_job +#: model:ir.model.constraint,message:queue_job.constraint_queue_job_channel_name_uniq +msgid "Channel complete name must be unique" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_queue_job_channel +#: model:ir.ui.menu,name:queue_job.menu_queue_job_channel +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_channel_form +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_channel_search +msgid "Channels" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__company_id +msgid "Company" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__channel_method_name +msgid "Complete Method Name" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__complete_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__channel +msgid "Complete Name" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__date_created +msgid "Created Date" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__create_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__create_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__create_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__create_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__create_uid +msgid "Created by" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Created date" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__create_date +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__create_date +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__create_date +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__create_date +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__create_date +msgid "Created on" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__retry +msgid "Current try" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Current try / max. retries" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__date_cancelled +msgid "Date Cancelled" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__date_done +msgid "Date Done" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependencies +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Dependencies" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_graph +msgid "Dependency Graph" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__name +msgid "Description" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_ir_model_fields__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__display_name +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__display_name +msgid "Display Name" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__done +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Done" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__date_enqueued +msgid "Enqueue Time" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__enqueued +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Enqueued" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__exc_name +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Exception" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__exc_info +msgid "Exception Info" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Exception Information" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__exc_message +msgid "Exception Message" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Exception message" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Exception:" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__eta +msgid "Execute only after" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__exec_time +msgid "Execution Time (avg)" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__failed +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Failed" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_ir_model_fields__ttype +msgid "Field Type" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_ir_model_fields +msgid "Fields" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_follower_ids +msgid "Followers" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_partner_ids +msgid "Followers (Partners)" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__activity_type_icon +msgid "Font awesome icon e.g. fa-tasks" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Graph" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Graph Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__graph_jobs_count +msgid "Graph Jobs Count" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__graph_uuid +msgid "Graph UUID" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__has_message +msgid "Has Message" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_ir_model_fields__id +#: model:ir.model.fields,field_description:queue_job.field_queue_job__id +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__id +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__id +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__id +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__id +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__id +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__id +msgid "ID" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_exception_icon +msgid "Icon" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__activity_exception_icon +msgid "Icon to indicate an exception activity." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__identity_key +msgid "Identity Key" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__message_needaction +msgid "If checked, new messages require your attention." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__message_has_error +msgid "If checked, some messages have a delivery error." +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_function.py:0 +msgid "Invalid job function: %s" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_is_follower +msgid "Is Follower" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_job_channel +msgid "Job Channels" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__job_function_id +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Job Function" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_queue_job_function +#: model:ir.model,name:queue_job.model_queue_job_function +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__job_function_ids +#: model:ir.ui.menu,name:queue_job.menu_queue_job_function +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_function_form +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_function_search +msgid "Job Functions" +msgstr "" + +#. module: queue_job +#: model:ir.module.category,name:queue_job.module_category_queue_job +#: model:ir.ui.menu,name:queue_job.menu_queue_job_root +#: model:res.groups.privilege,name:queue_job.privilege_queue_job +msgid "Job Queue" +msgstr "" + +#. module: queue_job +#: model:res.groups,name:queue_job.group_queue_job_manager +msgid "Job Queue Manager" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__ir_model_fields__ttype__job_serialized +msgid "Job Serialized" +msgstr "" + +#. module: queue_job +#: model:mail.message.subtype,name:queue_job.mt_job_failed +msgid "Job failed" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__job_ids +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__job_ids +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__job_ids +#: model:ir.ui.menu,name:queue_job.menu_queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_graph +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_pivot +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Jobs for graph %s" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs +msgid "Kwargs" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Last 24 hours" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Last 30 days" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Last 7 days" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__write_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__write_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__write_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__write_uid +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__write_date +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__write_date +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_cancelled__write_date +#: model:ir.model.fields,field_description:queue_job.field_queue_jobs_to_done__write_date +#: model:ir.model.fields,field_description:queue_job.field_queue_requeue_job__write_date +msgid "Last Updated on" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Manually set to done by %s" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__max_retries +msgid "Max. retries" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_has_error +msgid "Message Delivery error" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_ids +msgid "Messages" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__method +msgid "Method" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__method_name +msgid "Method Name" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__model_name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__model_id +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Model" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_function.py:0 +msgid "Model %s not found" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline +msgid "My Activity Deadline" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__name +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__name +msgid "Name" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_date_deadline +msgid "Next Activity Deadline" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_summary +msgid "Next Activity Summary" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_type_id +msgid "Next Activity Type" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "No action available for this job" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Not allowed to change field(s): %s" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_needaction_counter +msgid "Number of Actions" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__message_has_error_counter +msgid "Number of errors" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__message_needaction_counter +msgid "Number of messages requiring action" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__message_has_error_counter +msgid "Number of messages with delivery error" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id +msgid "Parent Channel" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_channel.py:0 +msgid "Parent channel required." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_retry_pattern +msgid "" +"Pattern expressing from the count of retries on retryable errors, the number " +"of of seconds to postpone the next execution. Setting the number of seconds " +"to a 2-element tuple or list will randomize the retry interval between the 2 " +"values.\n" +"Example: {1: 10, 5: 20, 10: 30, 15: 300}.\n" +"Example: {1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}.\n" +"See the module description for details." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__pending +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Pending" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Priority" +msgstr "" + +#. module: queue_job +#: model:ir.ui.menu,name:queue_job.menu_queue +msgid "Queue" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_lock__queue_job_id +msgid "Queue Job" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_job_lock +msgid "Queue Job Lock" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__records +msgid "Record(s)" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Related" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__edit_related_action +msgid "Related Action" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__related_action +msgid "Related Action (serialized)" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Related Record" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "Related Records" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_tree +msgid "Remaining days to execute" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__removal_interval +msgid "Removal Interval" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_requeue_job +msgid "Requeue" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Requeue Job" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_requeue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_requeue_job +msgid "Requeue Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_user_id +msgid "Responsible User" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__result +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Result" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Results" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__edit_retry_pattern +msgid "Retry Pattern" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__retry_pattern +msgid "Retry Pattern (serialized)" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_jobs_to_done +msgid "Set all selected jobs to done" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_done +msgid "Set jobs done" +msgstr "" + +#. module: queue_job +#: model:ir.actions.act_window,name:queue_job.action_set_jobs_done +msgid "Set jobs to done" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Set to 'Done'" +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_done +msgid "Set to done" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__graph_uuid +msgid "Single shared identifier of a Graph. Empty for a single job." +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "" +"Something bad happened during the execution of the job. More details in the " +"'Exception Information' section." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__date_started +msgid "Start Date" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__started +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Started" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__state +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "State" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__activity_state +msgid "" +"Status based on activities\n" +"Overdue: Due date is already passed\n" +"Today: Activity date is today\n" +"Planned: Future activities." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__func_string +msgid "Task" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_related_action +msgid "" +"The action when the button *Related Action* is used on a job. The default " +"action is to open the view of the record related to the job. Configured as a " +"dictionary with optional keys: enable, func_name, kwargs.\n" +"See the module description for details." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__max_retries +msgid "" +"The job will fail if the number of tries reach the max. retries.\n" +"Retries are infinite when empty." +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_cancelled +msgid "The selected jobs will be cancelled." +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_requeue_job +msgid "The selected jobs will be requeued." +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_set_jobs_done +msgid "The selected jobs will be set to done." +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form +msgid "Time (s)" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__exec_time +msgid "Time required to execute this job in seconds. Average when grouped." +msgstr "" + +#. module: queue_job +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Tried many times" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__activity_exception_decoration +msgid "Type of the exception activity on record." +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__uuid +msgid "UUID" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_function.py:0 +msgid "" +"Unexpected format of Related Action for %s.\n" +"Example of valid format:\n" +"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" " +"{{\"limit\": 10}}}}" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job_function.py:0 +msgid "" +"Unexpected format of Retry Pattern for %s.\n" +"Example of valid formats:\n" +"{{1: 300, 5: 600, 10: 1200, 15: 3000}}\n" +"{{1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}}" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__user_id +msgid "User ID" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields.selection,name:queue_job.selection__queue_job__state__wait_dependencies +#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search +msgid "Wait Dependencies" +msgstr "" + +#. module: queue_job +#: model:ir.model,name:queue_job.model_queue_requeue_job +msgid "Wizard to requeue a selection of jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__worker_pid +msgid "Worker Pid" +msgstr "" + +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/models/queue_job.py:0 +msgid "id" +msgstr "" diff --git a/queue_job/i18n/it.po b/queue_job/i18n/it.po index 89b041cb07..669a1dd647 100644 --- a/queue_job/i18n/it.po +++ b/queue_job/i18n/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2026-06-03 09:46+0000\n" +"PO-Revision-Date: 2026-10-30 10:46+0000\n" "Last-Translator: mymage \n" "Language-Team: none\n" "Language: it\n" @@ -85,11 +85,6 @@ msgstr "Argomenti" msgid "Attachment Count" msgstr "Conteggio allegati" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "Auto pulizia coda lavoro" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -124,6 +119,12 @@ msgstr "Annulla lavori" msgid "Cancelled" msgstr "Annullata" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "Annullato perché un lavoro da cui dipende è stato cannullato" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -238,6 +239,16 @@ msgstr "Dipendenze" msgid "Dependency Graph" msgstr "Grafico dipendenza" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "Dipendenza lavori" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "Lavori dipendenti" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -473,12 +484,22 @@ msgstr "Lavro fallito" msgid "Jobs" msgstr "Lavori" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "Lavori che dipendono da questo lavoro." + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "Lavori per grafico %s" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "Lavori da cui dipende questo lavoro." + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -561,6 +582,13 @@ msgstr "Modello" msgid "Model %s not found" msgstr "Modello %s non trovato" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" +"Modello funziona da chiamare se il lavoro fallisce e non verrà ricevuto." + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -619,6 +647,11 @@ msgstr "Numero di messaggi che richiedono un'azione" msgid "Number of messages with delivery error" msgstr "Numero di messaggi con errore di consegna" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "Metodo al fallimento" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -911,8 +944,8 @@ msgid "" msgstr "" "Formato inaspettato di azione colegata per %s.\n" "Esempio di formato valido:\n" -"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" {" -"{\"limit\": 10}}}}" +"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" " +"{{\"limit\": 10}}}}" #. module: queue_job #. odoo-python @@ -955,6 +988,9 @@ msgstr "PID worker" msgid "id" msgstr "id" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "Auto pulizia coda lavoro" + #~ msgid "Cancelled by {}" #~ msgstr "Annullato da {}" diff --git a/queue_job/i18n/nl.po b/queue_job/i18n/nl.po index 69820f9181..e57bc001bd 100644 --- a/queue_job/i18n/nl.po +++ b/queue_job/i18n/nl.po @@ -76,11 +76,6 @@ msgstr "" msgid "Attachment Count" msgstr "" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -115,6 +110,12 @@ msgstr "" msgid "Cancelled" msgstr "" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -229,6 +230,16 @@ msgstr "" msgid "Dependency Graph" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -464,12 +475,22 @@ msgstr "" msgid "Jobs" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -552,6 +573,12 @@ msgstr "" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -610,6 +637,11 @@ msgstr "" msgid "Number of messages with delivery error" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" diff --git a/queue_job/i18n/nl_NL.po b/queue_job/i18n/nl_NL.po index 45a4d8feee..80aeaaf07a 100644 --- a/queue_job/i18n/nl_NL.po +++ b/queue_job/i18n/nl_NL.po @@ -78,11 +78,6 @@ msgstr "Args" msgid "Attachment Count" msgstr "Aantal bijlagen" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "AutoVacuum wachtrijtaken" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -117,6 +112,12 @@ msgstr "Taken annuleren" msgid "Cancelled" msgstr "Geannuleerd" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -231,6 +232,16 @@ msgstr "Afhankelijkheden" msgid "Dependency Graph" msgstr "Afhankelijkheidsgrafiek" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -466,12 +477,22 @@ msgstr "Taak mislukt" msgid "Jobs" msgstr "Taken" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "Taken voor grafiek %s" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -554,6 +575,12 @@ msgstr "Model" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -612,6 +639,11 @@ msgstr "Aantal berichten dat een actie vereist" msgid "Number of messages with delivery error" msgstr "Aantal berichten met een afleverfout" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -943,6 +975,9 @@ msgstr "Werknemer PID" msgid "id" msgstr "" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "AutoVacuum wachtrijtaken" + #~ msgid "Cancelled by {}" #~ msgstr "Geannuleerd door {}" diff --git a/queue_job/i18n/queue_job.pot b/queue_job/i18n/queue_job.pot index 803118839d..adda00d40b 100644 --- a/queue_job/i18n/queue_job.pot +++ b/queue_job/i18n/queue_job.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 19.0\n" +"Project-Id-Version: Odoo Server 20.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -13,6 +13,763 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: queue_job +#: model:ir.module.module,description:base.module_queue_job +msgid "" +".. image:: https://odoo-community.org/readme-banner-image\n" +" :target: https://odoo-community.org/get-involved?utm_source=readme\n" +" :alt: Odoo Community Association\n" +"\n" +"=========\n" +"Job Queue\n" +"=========\n" +"\n" +".. \n" +" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +" !! This file is generated by oca-gen-addon-readme !!\n" +" !! changes will be overwritten. !!\n" +" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +" !! source digest: sha256:8fe930e0d2082bf352442794a848d2931d0f853a2f5e1b0d066f10d4c68fb33f\n" +" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +"\n" +".. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png\n" +" :target: https://odoo-community.org/page/development-status\n" +" :alt: Mature\n" +".. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png\n" +" :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html\n" +" :alt: License: LGPL-3\n" +".. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github\n" +" :target: https://github.com/OCA/queue/tree/20.0/queue_job\n" +" :alt: OCA/queue\n" +".. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png\n" +" :target: https://translation.odoo-community.org/projects/queue-20-0/queue-20-0-queue_job\n" +" :alt: Translate me on Weblate\n" +".. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png\n" +" :target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=20.0\n" +" :alt: Try me on Runboat\n" +"\n" +"|badge1| |badge2| |badge3| |badge4| |badge5|\n" +"\n" +"This addon adds an integrated Job Queue to Odoo.\n" +"\n" +"It allows to postpone method calls executed asynchronously.\n" +"\n" +"Jobs are executed in the background by a ``Jobrunner``, in their own\n" +"transaction.\n" +"\n" +"Example:\n" +"\n" +".. code:: python\n" +"\n" +" from odoo import models, fields, api\n" +"\n" +" class MyModel(models.Model):\n" +" _name = 'my.model'\n" +"\n" +" def my_method(self, a, k=None):\n" +" _logger.info('executed with a: %s and k: %s', a, k)\n" +"\n" +"\n" +" class MyOtherModel(models.Model):\n" +" _name = 'my.other.model'\n" +"\n" +" def button_do_stuff(self):\n" +" self.env['my.model'].with_delay().my_method('a', k=2)\n" +"\n" +"In the snippet of code above, when we call ``button_do_stuff``, a job\n" +"**capturing the method and arguments** will be postponed. It will be\n" +"executed as soon as the Jobrunner has a free bucket, which can be\n" +"instantaneous if no other job is running.\n" +"\n" +"Features:\n" +"\n" +"- Views for jobs, jobs are stored in PostgreSQL\n" +"- Jobrunner: execute the jobs, highly efficient thanks to PostgreSQL's\n" +" NOTIFY\n" +"- Channels: give a capacity for the root channel and its sub-channels\n" +" and segregate jobs in them. Allow for instance to restrict heavy jobs\n" +" to be executed one at a time while little ones are executed 4 at a\n" +" times.\n" +"- Retries: Ability to retry jobs by raising a type of exception\n" +"- Retry Pattern: the 3 first tries, retry after 10 seconds, the 5 next\n" +" tries, retry after 1 minutes, ...\n" +"- Job properties: priorities, estimated time of arrival (ETA), custom\n" +" description, number of retries\n" +"- Related Actions: link an action on the job view, such as open the\n" +" record concerned by the job\n" +"\n" +"**Table of contents**\n" +"\n" +".. contents::\n" +" :local:\n" +"\n" +"Use Cases / Context\n" +"===================\n" +"\n" +"Odoo treats task synchronously, like when you import a list of products\n" +"it will treat each line in one big task. \"Queue job\" gives you the\n" +"ability to detail big tasks in many smaller ones.\n" +"\n" +"Imagine you have a lot of data to change for thousand orders, you can do\n" +"it in one step and cause a heavy load on the server, and this may affect\n" +"the performance of Odoo. With queue_job you can divide the work in jobs\n" +"and run thousand jobs (one job for each orders). An other benefit is if\n" +"one line failed it doesn't block the processing of the others, as the\n" +"jobs are independent. Plus you can schedule the jobs and set a number of\n" +"retries.\n" +"\n" +"Here are some community usage examples:\n" +"\n" +"- Mass sending invoices:\n" +" `account_invoice_mass_sending `__\n" +"- Import data in the background:\n" +" `base_import_async `__\n" +"- Export data in the background:\n" +" `base_export_async `__\n" +"- Generate contract invoices with jobs:\n" +" `contract_queue_job `__\n" +"- Generate partner invoices with\n" +" jobs:`partner_invoicing_mode `__\n" +"- Process the Sales Automatic Workflow actions with jobs:\n" +" `sale_automatic_workflow_job `__\n" +"\n" +"Installation\n" +"============\n" +"\n" +"Be sure to have the ``requests`` library.\n" +"\n" +"Configuration\n" +"=============\n" +"\n" +"- Using environment variables and command line:\n" +"\n" +" - Adjust environment variables (optional):\n" +"\n" +" - ``ODOO_QUEUE_JOB_CHANNELS=root:4`` or any other channels\n" +" configuration. The default is ``root:1``\n" +" - ``ODOO_QUEUE_JOB_PORT=8069``, default ``--http-port``\n" +" - ``ODOO_QUEUE_JOB_SCHEME=https``, default ``http``\n" +" - ``ODOO_QUEUE_JOB_HOST=load-balancer``, default\n" +" ``--http-interface`` or ``localhost`` if unset\n" +" - ``ODOO_QUEUE_JOB_HTTP_AUTH_USER=jobrunner``, default empty\n" +" - ``ODOO_QUEUE_JOB_HTTP_AUTH_PASSWORD=s3cr3t``, default empty\n" +" - Start Odoo with ``--load=web,queue_job`` and ``--workers`` greater\n" +" than 1. [1]_\n" +"\n" +"- Using the Odoo configuration file:\n" +"\n" +".. code:: ini\n" +"\n" +" [options]\n" +" (...)\n" +" workers = 6\n" +" server_wide_modules = web,queue_job\n" +"\n" +" (...)\n" +" [queue_job]\n" +" channels = root:2\n" +" scheme = https\n" +" host = load-balancer\n" +" port = 443\n" +" http_auth_user = jobrunner\n" +" http_auth_password = s3cr3t\n" +"\n" +"- Confirm the runner is starting correctly by checking the odoo log\n" +" file:\n" +"\n" +"::\n" +"\n" +" ...INFO...queue_job.jobrunner.runner: starting\n" +" ...INFO...queue_job.jobrunner.runner: initializing database connections\n" +" ...INFO...queue_job.jobrunner.runner: queue job runner ready for db \n" +" ...INFO...queue_job.jobrunner.runner: database connections ready\n" +"\n" +"- Create jobs (eg using ``base_import_async``) and observe they start\n" +" immediately and in parallel.\n" +"- Tip: to enable debug logging for the queue job, use\n" +" ``--log-handler=odoo.addons.queue_job:DEBUG``\n" +"\n" +"- Jobs that remain in ``enqueued`` or ``started`` state (because, for\n" +" instance, their worker has been killed) will be automatically\n" +" re-queued.\n" +"\n" +".. [1]\n" +" It works with the threaded Odoo server too, although this way of\n" +" running Odoo is obviously not for production purposes.\n" +"\n" +"Usage\n" +"=====\n" +"\n" +"To use this module, you need to:\n" +"\n" +"1. Go to ``Job Queue`` menu\n" +"\n" +"Developers\n" +"----------\n" +"\n" +"Delaying jobs\n" +"~~~~~~~~~~~~~\n" +"\n" +"The fast way to enqueue a job for a method is to use ``with_delay()`` on\n" +"a record or model:\n" +"\n" +".. code:: python\n" +"\n" +" def button_done(self):\n" +" self.with_delay().print_confirmation_document(self.state)\n" +" self.write({\"state\": \"done\"})\n" +" return True\n" +"\n" +"Here, the method ``print_confirmation_document()`` will be executed\n" +"asynchronously as a job. ``with_delay()`` can take several parameters to\n" +"define more precisely how the job is executed (priority, ...).\n" +"\n" +"All the arguments passed to the method being delayed are stored in the\n" +"job and passed to the method when it is executed asynchronously,\n" +"including ``self``, so the current record is maintained during the job\n" +"execution (warning: the context is not kept).\n" +"\n" +"Dependencies can be expressed between jobs. To start a graph of jobs,\n" +"use ``delayable()`` on a record or model. The following is the\n" +"equivalent of ``with_delay()`` but using the long form:\n" +"\n" +".. code:: python\n" +"\n" +" def button_done(self):\n" +" delayable = self.delayable()\n" +" delayable.print_confirmation_document(self.state)\n" +" delayable.delay()\n" +" self.write({\"state\": \"done\"})\n" +" return True\n" +"\n" +"Methods of Delayable objects return itself, so it can be used as a\n" +"builder pattern, which in some cases allow to build the jobs\n" +"dynamically:\n" +"\n" +".. code:: python\n" +"\n" +" def button_generate_simple_with_delayable(self):\n" +" self.ensure_one()\n" +" # Introduction of a delayable object, using a builder pattern\n" +" # allowing to chain jobs or set properties. The delay() method\n" +" # on the delayable object actually stores the delayable objects\n" +" # in the queue_job table\n" +" (\n" +" self.delayable()\n" +" .generate_thumbnail((50, 50))\n" +" .set(priority=30)\n" +" .set(description=_(\"generate xxx\"))\n" +" .delay()\n" +" )\n" +"\n" +"The simplest way to define a dependency is to use ``.on_done(job)`` on a\n" +"Delayable:\n" +"\n" +".. code:: python\n" +"\n" +" def button_chain_done(self):\n" +" self.ensure_one()\n" +" job1 = self.browse(1).delayable().generate_thumbnail((50, 50))\n" +" job2 = self.browse(1).delayable().generate_thumbnail((50, 50))\n" +" job3 = self.browse(1).delayable().generate_thumbnail((50, 50))\n" +" # job 3 is executed when job 2 is done which is executed when job 1 is done\n" +" job1.on_done(job2.on_done(job3)).delay()\n" +"\n" +"Delayables can be chained to form more complex graphs using the\n" +"``chain()`` and ``group()`` primitives. A chain represents a sequence of\n" +"jobs to execute in order, a group represents jobs which can be executed\n" +"in parallel. Using ``chain()`` has the same effect as using several\n" +"nested ``on_done()`` but is more readable. Both can be combined to form\n" +"a graph, for instance we can group [A] of jobs, which blocks another\n" +"group [B] of jobs. When and only when all the jobs of the group [A] are\n" +"executed, the jobs of the group [B] are executed. The code would look\n" +"like:\n" +"\n" +".. code:: python\n" +"\n" +" from odoo.addons.queue_job.delay import group, chain\n" +"\n" +" def button_done(self):\n" +" group_a = group(self.delayable().method_foo(), self.delayable().method_bar())\n" +" group_b = group(self.delayable().method_baz(1), self.delayable().method_baz(2))\n" +" chain(group_a, group_b).delay()\n" +" self.write({\"state\": \"done\"})\n" +" return True\n" +"\n" +"When a failure happens in a graph of jobs, the execution of the jobs\n" +"that depend on the failed job stops. They remain in a state\n" +"``wait_dependencies`` until their \"parent\" job is successful. This can\n" +"happen in two ways: either the parent job retries and is successful on a\n" +"second try, either the parent job is manually \"set to done\" by a user.\n" +"In these two cases, the dependency is resolved and the graph will\n" +"continue to be processed. Alternatively, the failed job and all its\n" +"dependent jobs can be canceled by a user. The other jobs of the graph\n" +"that do not depend on the failed job continue their execution in any\n" +"case.\n" +"\n" +"Note: ``delay()`` must be called on the delayable, chain, or group which\n" +"is at the top of the graph. In the example above, if it was called on\n" +"``group_a``, then ``group_b`` would never be delayed (but a warning\n" +"would be shown).\n" +"\n" +"It is also possible to split a job into several jobs, each one\n" +"processing a part of the work. This can be useful to avoid very long\n" +"jobs, parallelize some task and get more specific errors. Usage is as\n" +"follows:\n" +"\n" +".. code:: python\n" +"\n" +" def button_split_delayable(self):\n" +" (\n" +" self # Can be a big recordset, let's say 1000 records\n" +" .delayable()\n" +" .generate_thumbnail((50, 50))\n" +" .set(priority=30)\n" +" .set(description=_(\"generate xxx\"))\n" +" .split(50) # Split the job in 20 jobs of 50 records each\n" +" .delay()\n" +" )\n" +"\n" +"The ``split()`` method takes a ``chain`` boolean keyword argument. If\n" +"set to True, the jobs will be chained, meaning that the next job will\n" +"only start when the previous one is done:\n" +"\n" +".. code:: python\n" +"\n" +" def button_increment_var(self):\n" +" (\n" +" self\n" +" .delayable()\n" +" .increment_counter()\n" +" .split(1, chain=True) # Will exceute the jobs one after the other\n" +" .delay()\n" +" )\n" +"\n" +"Enqueing Job Options\n" +"~~~~~~~~~~~~~~~~~~~~\n" +"\n" +"- priority: default is 10, the closest it is to 0, the faster it will be\n" +" executed\n" +"- eta: Estimated Time of Arrival of the job. It will not be executed\n" +" before this date/time\n" +"- max_retries: default is 5, maximum number of retries before giving up\n" +" and set the job state to 'failed'. A value of 0 means infinite\n" +" retries.\n" +"- description: human description of the job. If not set, description is\n" +" computed from the function doc or method name\n" +"- channel: the complete name of the channel to use to process the\n" +" function. If specified it overrides the one defined on the function\n" +"- identity_key: key uniquely identifying the job, if specified and a job\n" +" with the same key has not yet been run, the new job will not be\n" +" created\n" +"\n" +"Configure default options for jobs\n" +"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +"\n" +"In earlier versions, jobs could be configured using the ``@job``\n" +"decorator. This is now obsolete, they can be configured using optional\n" +"``queue.job.function`` and ``queue.job.channel`` XML records.\n" +"\n" +"Example of channel:\n" +"\n" +".. code:: XML\n" +"\n" +" \n" +" sale\n" +" \n" +" \n" +"\n" +"Example of job function:\n" +"\n" +".. code:: XML\n" +"\n" +" \n" +" \n" +" action_done\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"The general form for the ``name`` is: ``.method``.\n" +"\n" +"The channel, related action and retry pattern options are optional, they\n" +"are documented below.\n" +"\n" +"When writing modules, if 2+ modules add a job function or channel with\n" +"the same name (and parent for channels), they'll be merged in the same\n" +"record, even if they have different xmlids. On uninstall, the merged\n" +"record is deleted when all the modules using it are uninstalled.\n" +"\n" +"**Job function: model**\n" +"\n" +"If the function is defined in an abstract model, you can not write\n" +"````\n" +"but you have to define a function for each model that inherits from the\n" +"abstract model.\n" +"\n" +"**Job function: channel**\n" +"\n" +"The channel where the job will be delayed. The default channel is\n" +"``root``.\n" +"\n" +"**Job function: related action**\n" +"\n" +"The *Related Action* appears as a button on the Job's view. The button\n" +"will execute the defined action.\n" +"\n" +"The default one is to open the view of the record related to the job\n" +"(form view when there is a single record, list view for several\n" +"records). In many cases, the default related action is enough and\n" +"doesn't need customization, but it can be customized by providing a\n" +"dictionary on the job function:\n" +"\n" +".. code:: python\n" +"\n" +" {\n" +" \"enable\": False,\n" +" \"func_name\": \"related_action_partner\",\n" +" \"kwargs\": {\"name\": \"Partner\"},\n" +" }\n" +"\n" +"- ``enable``: when ``False``, the button has no effect (default:\n" +" ``True``)\n" +"- ``func_name``: name of the method on ``queue.job`` that returns an\n" +" action\n" +"- ``kwargs``: extra arguments to pass to the related action method\n" +"\n" +"Example of related action code:\n" +"\n" +".. code:: python\n" +"\n" +" class QueueJob(models.Model):\n" +" _inherit = 'queue.job'\n" +"\n" +" def related_action_partner(self, name):\n" +" self.ensure_one()\n" +" model = self.model_name\n" +" partner = self.records\n" +" action = {\n" +" 'name': name,\n" +" 'type': 'ir.actions.act_window',\n" +" 'res_model': model,\n" +" 'view_type': 'form',\n" +" 'view_mode': 'form',\n" +" 'res_id': partner.id,\n" +" }\n" +" return action\n" +"\n" +"**Job function: retry pattern**\n" +"\n" +"When a job fails with a retryable error type, it is automatically\n" +"retried later. By default, the retry is always 10 minutes later.\n" +"\n" +"A retry pattern can be configured on the job function. What a pattern\n" +"represents is \"from X tries, postpone to Y seconds\". It is expressed as\n" +"a dictionary where keys are tries and values are seconds to postpone as\n" +"integers:\n" +"\n" +".. code:: python\n" +"\n" +" {\n" +" 1: 10,\n" +" 5: 20,\n" +" 10: 30,\n" +" 15: 300,\n" +" }\n" +"\n" +"Based on this configuration, we can tell that:\n" +"\n" +"- 5 first retries are postponed 10 seconds later\n" +"- retries 5 to 10 postponed 20 seconds later\n" +"- retries 10 to 15 postponed 30 seconds later\n" +"- all subsequent retries postponed 5 minutes later\n" +"\n" +"**Job Context**\n" +"\n" +"The context of the recordset of the job, or any recordset passed in\n" +"arguments of a job, is transferred to the job according to an\n" +"allow-list.\n" +"\n" +"The default allow-list is (\"tz\", \"lang\", \"allowed_company_ids\",\n" +"\"force_company\", \"active_test\"). It can be customized in\n" +"``Base._job_prepare_context_before_enqueue_keys``. **Bypass jobs on\n" +"running Odoo**\n" +"\n" +"When you are developing (ie: connector modules) you might want to bypass\n" +"the queue job and run your code immediately.\n" +"\n" +"To do so you can set QUEUE_JOB\\__NO_DELAY=1 in your environment.\n" +"\n" +"**Bypass jobs in tests**\n" +"\n" +"When writing tests on job-related methods is always tricky to deal with\n" +"delayed recordsets. To make your testing life easier you can set\n" +"queue_job\\__no_delay=True in the context.\n" +"\n" +"Tip: you can do this at test case level like this\n" +"\n" +".. code:: python\n" +"\n" +" @classmethod\n" +" def setUpClass(cls):\n" +" super().setUpClass()\n" +" cls.env = cls.env(context=dict(\n" +" cls.env.context,\n" +" queue_job__no_delay=True, # no jobs thanks\n" +" ))\n" +"\n" +"Then all your tests execute the job methods synchronously without\n" +"delaying any jobs.\n" +"\n" +"Testing\n" +"~~~~~~~\n" +"\n" +"**Asserting enqueued jobs**\n" +"\n" +"The recommended way to test jobs, rather than running them directly and\n" +"synchronously is to split the tests in two parts:\n" +"\n" +" - one test where the job is mocked (trap jobs with ``trap_jobs()``\n" +" and the test only verifies that the job has been delayed with the\n" +" expected arguments\n" +" - one test that only calls the method of the job synchronously, to\n" +" validate the proper behavior of this method only\n" +"\n" +"Proceeding this way means that you can prove that jobs will be enqueued\n" +"properly at runtime, and it ensures your code does not have a different\n" +"behavior in tests and in production (because running your jobs\n" +"synchronously may have a different behavior as they are in the same\n" +"transaction / in the middle of the method). Additionally, it gives more\n" +"control on the arguments you want to pass when calling the job's method\n" +"(synchronously, this time, in the second type of tests), and it makes\n" +"tests smaller.\n" +"\n" +"The best way to run such assertions on the enqueued jobs is to use\n" +"``odoo.addons.queue_job.tests.common.trap_jobs()``.\n" +"\n" +"A very small example (more details in ``tests/common.py``):\n" +"\n" +".. code:: python\n" +"\n" +" # code\n" +" def my_job_method(self, name, count):\n" +" self.write({\"name\": \" \".join([name] * count)\n" +"\n" +" def method_to_test(self):\n" +" count = self.env[\"other.model\"].search_count([])\n" +" self.with_delay(priority=15).my_job_method(\"Hi!\", count=count)\n" +" return count\n" +"\n" +" # tests\n" +" from odoo.addons.queue_job.tests.common import trap_jobs\n" +"\n" +" # first test only check the expected behavior of the method and the proper\n" +" # enqueuing of jobs\n" +" def test_method_to_test(self):\n" +" with trap_jobs() as trap:\n" +" result = self.env[\"model\"].method_to_test()\n" +" expected_count = 12\n" +"\n" +" trap.assert_jobs_count(1, only=self.env[\"model\"].my_job_method)\n" +" trap.assert_enqueued_job(\n" +" self.env[\"model\"].my_job_method,\n" +" args=(\"Hi!\",),\n" +" kwargs=dict(count=expected_count),\n" +" properties=dict(priority=15)\n" +" )\n" +" self.assertEqual(result, expected_count)\n" +"\n" +"\n" +" # second test to validate the behavior of the job unitarily\n" +" def test_my_job_method(self):\n" +" record = self.env[\"model\"].browse(1)\n" +" record.my_job_method(\"Hi!\", count=12)\n" +" self.assertEqual(record.name, \"Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi!\")\n" +"\n" +"If you prefer, you can still test the whole thing in a single test, by\n" +"calling ``jobs_tester.perform_enqueued_jobs()`` in your test.\n" +"\n" +".. code:: python\n" +"\n" +" def test_method_to_test(self):\n" +" with trap_jobs() as trap:\n" +" result = self.env[\"model\"].method_to_test()\n" +" expected_count = 12\n" +"\n" +" trap.assert_jobs_count(1, only=self.env[\"model\"].my_job_method)\n" +" trap.assert_enqueued_job(\n" +" self.env[\"model\"].my_job_method,\n" +" args=(\"Hi!\",),\n" +" kwargs=dict(count=expected_count),\n" +" properties=dict(priority=15)\n" +" )\n" +" self.assertEqual(result, expected_count)\n" +"\n" +" trap.perform_enqueued_jobs()\n" +"\n" +" record = self.env[\"model\"].browse(1)\n" +" record.my_job_method(\"Hi!\", count=12)\n" +" self.assertEqual(record.name, \"Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi! Hi!\")\n" +"\n" +"**Execute jobs synchronously when running Odoo**\n" +"\n" +"When you are developing (ie: connector modules) you might want to bypass\n" +"the queue job and run your code immediately.\n" +"\n" +"To do so you can set ``QUEUE_JOB__NO_DELAY=1`` in your environment.\n" +"\n" +"Warning\n" +"\n" +"Do not do this in production\n" +"\n" +"**Execute jobs synchronously in tests**\n" +"\n" +"You should use ``trap_jobs``, really, but if for any reason you could\n" +"not use it, and still need to have job methods executed synchronously in\n" +"your tests, you can do so by setting ``queue_job__no_delay=True`` in the\n" +"context.\n" +"\n" +"Tip: you can do this at test case level like this\n" +"\n" +".. code:: python\n" +"\n" +" @classmethod\n" +" def setUpClass(cls):\n" +" super().setUpClass()\n" +" cls.env = cls.env(context=dict(\n" +" cls.env.context,\n" +" queue_job__no_delay=True, # no jobs thanks\n" +" ))\n" +"\n" +"Then all your tests execute the job methods synchronously without\n" +"delaying any jobs.\n" +"\n" +"In tests you'll have to mute the logger like:\n" +"\n" +" @mute_logger('odoo.addons.queue_job.models.base')\n" +"\n" +"Note\n" +"\n" +"in graphs of jobs, the ``queue_job__no_delay`` context key must be in at\n" +"least one job's env of the graph for the whole graph to be executed\n" +"synchronously\n" +"\n" +"Tips and tricks\n" +"~~~~~~~~~~~~~~~\n" +"\n" +"- **Idempotency**\n" +" (https://www.restapitutorial.com/lessons/idempotency.html): The\n" +" queue_job should be idempotent so they can be retried several times\n" +" without impact on the data.\n" +"- **The job should test at the very beginning its relevance**: the\n" +" moment the job will be executed is unknown by design. So the first\n" +" task of a job should be to check if the related work is still relevant\n" +" at the moment of the execution.\n" +"\n" +"Patterns\n" +"~~~~~~~~\n" +"\n" +"Through the time, two main patterns emerged:\n" +"\n" +"1. For data exposed to users, a model should store the data and the\n" +" model should be the creator of the job. The job is kept hidden from\n" +" the users\n" +"2. For technical data, that are not exposed to the users, it is\n" +" generally alright to create directly jobs with data passed as\n" +" arguments to the job, without intermediary models.\n" +"\n" +"Known issues / Roadmap\n" +"======================\n" +"\n" +"- After creating a new database or installing ``queue_job`` on an\n" +" existing database, Odoo must be restarted for the runner to detect it.\n" +"\n" +"Changelog\n" +"=========\n" +"\n" +"Next\n" +"----\n" +"\n" +"- [ADD] Run jobrunner as a worker process instead of a thread in the\n" +" main process (when running with --workers > 0)\n" +"- [REF] ``@job`` and ``@related_action`` deprecated, any method can be\n" +" delayed, and configured using ``queue.job.function`` records\n" +"- [MIGRATION] from 13.0 branched at rev. e24ff4b\n" +"\n" +"Bug Tracker\n" +"===========\n" +"\n" +"Bugs are tracked on `GitHub Issues `_.\n" +"In case of trouble, please check there if your issue has already been reported.\n" +"If you spotted it first, help us to smash it by providing a detailed and welcomed\n" +"`feedback `_.\n" +"\n" +"Do not contact contributors directly about support or help with technical issues.\n" +"\n" +"Credits\n" +"=======\n" +"\n" +"Authors\n" +"-------\n" +"\n" +"* Camptocamp\n" +"* ACSONE SA/NV\n" +"\n" +"Contributors\n" +"------------\n" +"\n" +"- Guewen Baconnier \n" +"- Stéphane Bidoul \n" +"- Matthieu Dietrich \n" +"- Jos De Graeve \n" +"- David Lefever \n" +"- Laurent Mignon \n" +"- Laetitia Gangloff \n" +"- Cédric Pigeon \n" +"- Tatiana Deribina \n" +"- Souheil Bejaoui \n" +"- Eric Antones \n" +"- Simone Orsi \n" +"- Nguyen Minh Chien \n" +"- Tran Quoc Duong \n" +"- Vo Hong Thien \n" +"\n" +"Other credits\n" +"-------------\n" +"\n" +"The migration of this module from 17.0 to 18.0 was financially supported\n" +"by Camptocamp.\n" +"\n" +"Maintainers\n" +"-----------\n" +"\n" +"This module is maintained by the OCA.\n" +"\n" +".. image:: https://odoo-community.org/logo.png\n" +" :alt: Odoo Community Association\n" +" :target: https://odoo-community.org\n" +"\n" +"OCA, or the Odoo Community Association, is a nonprofit organization whose\n" +"mission is to support the collaborative development of Odoo features and\n" +"promote its widespread use.\n" +"\n" +".. |maintainer-guewen| image:: https://github.com/guewen.png?size=40px\n" +" :target: https://github.com/guewen\n" +" :alt: guewen\n" +".. |maintainer-sbidoul| image:: https://github.com/sbidoul.png?size=40px\n" +" :target: https://github.com/sbidoul\n" +" :alt: sbidoul\n" +"\n" +"Current `maintainers `__:\n" +"\n" +"|maintainer-guewen| |maintainer-sbidoul| \n" +"\n" +"This module is part of the `OCA/queue `_ project on GitHub.\n" +"\n" +"You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.\n" +msgstr "" + #. module: queue_job #: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form msgid "" @@ -41,6 +798,11 @@ msgstr "" msgid "Activity Exception Decoration" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_plans_ids +msgid "Activity Plans" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__activity_state msgid "Activity State" @@ -74,11 +836,6 @@ msgstr "" msgid "Attachment Count" msgstr "" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -113,6 +870,12 @@ msgstr "" msgid "Cancelled" msgstr "" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -227,6 +990,16 @@ msgstr "" msgid "Dependency Graph" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -309,13 +1082,13 @@ msgid "Failed" msgstr "" #. module: queue_job -#: model:ir.model.fields,field_description:queue_job.field_ir_model_fields__ttype -msgid "Field Type" +#: model:ir.model,name:queue_job.model_ir_model_fields +msgid "Field" msgstr "" #. module: queue_job -#: model:ir.model,name:queue_job.model_ir_model_fields -msgid "Fields" +#: model:ir.model.fields,field_description:queue_job.field_ir_model_fields__ttype +msgid "Field Type" msgstr "" #. module: queue_job @@ -328,11 +1101,6 @@ msgstr "" msgid "Followers (Partners)" msgstr "" -#. module: queue_job -#: model:ir.model.fields,help:queue_job.field_queue_job__activity_type_icon -msgid "Font awesome icon e.g. fa-tasks" -msgstr "" - #. module: queue_job #: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search msgid "Graph" @@ -429,6 +1197,7 @@ msgstr "" #. module: queue_job #: model:ir.module.category,name:queue_job.module_category_queue_job +#: model:ir.module.module,shortdesc:base.module_queue_job #: model:ir.ui.menu,name:queue_job.menu_queue_job_root #: model:res.groups.privilege,name:queue_job.privilege_queue_job msgid "Job Queue" @@ -462,12 +1231,22 @@ msgstr "" msgid "Jobs" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -512,6 +1291,11 @@ msgstr "" msgid "Manually set to done by %s" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__activity_type_icon +msgid "Material Symbols icon e.g. checklist" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__max_retries msgid "Max. retries" @@ -550,6 +1334,12 @@ msgstr "" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -576,6 +1366,11 @@ msgstr "" msgid "Next Activity Type" msgstr "" +#. module: queue_job +#: model:res.groups.privilege,placeholder:queue_job.privilege_queue_job +msgid "No" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -608,6 +1403,11 @@ msgstr "" msgid "Number of messages with delivery error" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" diff --git a/queue_job/i18n/tr.po b/queue_job/i18n/tr.po index 445886f6b3..479a7540e8 100644 --- a/queue_job/i18n/tr.po +++ b/queue_job/i18n/tr.po @@ -81,11 +81,6 @@ msgstr "Argümanlar" msgid "Attachment Count" msgstr "Ek Sayısı" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "Otomatik Temizleme İş Kuyruğu" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -120,6 +115,12 @@ msgstr "İşleri iptal et" msgid "Cancelled" msgstr "İptal Edildi" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -234,6 +235,16 @@ msgstr "Bağımlılıklar" msgid "Dependency Graph" msgstr "Bağımlılık Grafiği" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -469,12 +480,22 @@ msgstr "İş başarısız oldu" msgid "Jobs" msgstr "İşler" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "Grafik için işler %s" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -557,6 +578,12 @@ msgstr "" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -615,6 +642,11 @@ msgstr "Eylem gerektiren mesaj sayısı" msgid "Number of messages with delivery error" msgstr "Teslimat hatası içeren mesaj sayısı" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -943,6 +975,9 @@ msgstr "Çalışan Pid" msgid "id" msgstr "" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "Otomatik Temizleme İş Kuyruğu" + #~ msgid "Cancelled by {}" #~ msgstr "İptal eden: {}" diff --git a/queue_job/i18n/tr_TR.po b/queue_job/i18n/tr_TR.po index 56c8481375..4606d0e471 100644 --- a/queue_job/i18n/tr_TR.po +++ b/queue_job/i18n/tr_TR.po @@ -76,11 +76,6 @@ msgstr "" msgid "Attachment Count" msgstr "" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -115,6 +110,12 @@ msgstr "" msgid "Cancelled" msgstr "" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -229,6 +230,16 @@ msgstr "" msgid "Dependency Graph" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -464,12 +475,22 @@ msgstr "" msgid "Jobs" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -552,6 +573,12 @@ msgstr "" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -610,6 +637,11 @@ msgstr "" msgid "Number of messages with delivery error" msgstr "" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" diff --git a/queue_job/i18n/zh_CN.po b/queue_job/i18n/zh_CN.po index 350634577b..866c24bcc5 100644 --- a/queue_job/i18n/zh_CN.po +++ b/queue_job/i18n/zh_CN.po @@ -81,11 +81,6 @@ msgstr "位置参数" msgid "Attachment Count" msgstr "附件数量" -#. module: queue_job -#: model:ir.actions.server,name:queue_job.ir_cron_autovacuum_queue_jobs_ir_actions_server -msgid "AutoVacuum Job Queue" -msgstr "自动清空作业队列" - #. module: queue_job #: model:ir.model,name:queue_job.model_base msgid "Base" @@ -120,6 +115,12 @@ msgstr "取消作业" msgid "Cancelled" msgstr "已取消" +#. module: queue_job +#. odoo-python +#: code:addons/queue_job/job.py:0 +msgid "Cancelled because a job it depends on was cancelled" +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 @@ -234,6 +235,16 @@ msgstr "依赖项" msgid "Dependency Graph" msgstr "依赖关系图" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependency_ids +msgid "Dependency Jobs" +msgstr "" + +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job__dependent_ids +msgid "Dependent Jobs" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__name msgid "Description" @@ -469,12 +480,22 @@ msgstr "作业失败" msgid "Jobs" msgstr "作业" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependent_ids +msgid "Jobs depending on this job." +msgstr "" + #. module: queue_job #. odoo-python #: code:addons/queue_job/models/queue_job.py:0 msgid "Jobs for graph %s" msgstr "图表 %s 的作业" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job__dependency_ids +msgid "Jobs this job depends on." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__kwargs msgid "Kwargs" @@ -557,6 +578,12 @@ msgstr "模型" msgid "Model %s not found" msgstr "" +#. module: queue_job +#: model:ir.model.fields,help:queue_job.field_queue_job_function__on_fail_method +msgid "" +"Model function to be called if the job is failed and will not be retried." +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job__my_activity_date_deadline msgid "My Activity Deadline" @@ -615,6 +642,11 @@ msgstr "需要处理的消息数量" msgid "Number of messages with delivery error" msgstr "递送错误消息数量" +#. module: queue_job +#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__on_fail_method +msgid "On Fail Method" +msgstr "" + #. module: queue_job #: model:ir.model.fields,field_description:queue_job.field_queue_job_channel__parent_id msgid "Parent Channel" @@ -937,6 +969,9 @@ msgstr "工作进程PID" msgid "id" msgstr "" +#~ msgid "AutoVacuum Job Queue" +#~ msgstr "自动清空作业队列" + #~ msgid "Group By" #~ msgstr "分组" diff --git a/queue_job/job.py b/queue_job/job.py index 86314499bd..d987d1e6bc 100644 --- a/queue_job/job.py +++ b/queue_job/job.py @@ -13,9 +13,30 @@ from random import randint import odoo +from odoo.models import BaseModel from .exception import FailedJobError, NoSuchJobError, RetryableJobError + +def _rebind_to_cr(value, cr): + """Rebind any BaseModel inside ``value`` to the cursor ``cr``. + + Recurses into lists, tuples and dicts. Preserves uid/su/context of each + inner env - only the cursor is swapped. Recordsets already bound to + ``cr`` and non-recordset values pass through untouched. Containers are + rebuilt, so in-place changes to the result are lost. + """ + if isinstance(value, BaseModel): + if value.env.cr is cr: + return value + return value.with_env(value.env(cr=cr)) + if isinstance(value, (list, tuple)): + return type(value)(_rebind_to_cr(v, cr) for v in value) + if isinstance(value, dict): + return {k: _rebind_to_cr(v, cr) for k, v in value.items()} + return value + + WAIT_DEPENDENCIES = "wait_dependencies" PENDING = "pending" ENQUEUED = "enqueued" @@ -410,6 +431,12 @@ def __init__( self.job_config = ( self.env["queue.job.function"].sudo().job_config(self.job_function_name) ) + on_fail_method_name = self.job_config.on_fail_method_name + if on_fail_method_name and not _is_model_method( + getattr(self.recordset, on_fail_method_name, None) + ): + raise TypeError("Job accepts only methods of Models") + self.on_fail_method_name = on_fail_method_name self.state = PENDING @@ -434,7 +461,7 @@ def __init__( if self.priority is None: self.priority = DEFAULT_PRIORITY - self.date_created = datetime.now() + self.date_created = datetime.now() # noqa: DTZ005 self._description = description if isinstance(identity_key, str): @@ -497,7 +524,7 @@ def perform(self): elif not self.max_retries: # infinite retries raise elif self.retry >= self.max_retries: - type_, value, traceback = sys.exc_info() + type_, value, _traceback = sys.exc_info() # change the exception type but keep the original # traceback and message: # http://blog.ianbicking.org/2007/09/12/re-raising-exceptions/ @@ -513,54 +540,51 @@ def perform(self): def in_temporary_env(self): with self.env.registry.cursor() as new_cr: env = self.env - self._env = env(cr=new_cr) try: + self._env = env(cr=new_cr) yield finally: self._env = env - def _get_common_dependent_jobs_query(self): - return """ - UPDATE queue_job - SET state = %s - FROM ( - SELECT child.id, array_agg(parent.state) as parent_states - FROM queue_job job - JOIN LATERAL - json_array_elements_text( - job.dependencies::json->'reverse_depends_on' - ) child_deps ON true - JOIN queue_job child - ON child.graph_uuid = job.graph_uuid - AND child.uuid = child_deps - JOIN LATERAL - json_array_elements_text( - child.dependencies::json->'depends_on' - ) parent_deps ON true - JOIN queue_job parent - ON parent.graph_uuid = job.graph_uuid - AND parent.uuid = parent_deps - WHERE job.uuid = %s - GROUP BY child.id - ) jobs - WHERE - queue_job.id = jobs.id - AND %s = ALL(jobs.parent_states) - AND state = %s; - """ - def should_check_dependents(self): return any(self.__reverse_depends_on_uuids) def enqueue_waiting(self): - sql = self._get_common_dependent_jobs_query() - self.env.cr.execute(sql, (PENDING, self.uuid, DONE, WAIT_DEPENDENCIES)) - self.env["queue.job"].invalidate_model(["state"]) + dependents = ( + self.env["queue.job"] + .sudo() + .search( + [ + ("graph_uuid", "=", self.graph_uuid), + ("state", "=", WAIT_DEPENDENCIES), + ("dependency_ids", "any", [("uuid", "=", self.uuid)]), + ("dependency_ids", "not any", [("state", "!=", DONE)]), + ] + ) + ) + dependents.state = PENDING def cancel_dependent_jobs(self): - sql = self._get_common_dependent_jobs_query() - self.env.cr.execute(sql, (CANCELLED, self.uuid, CANCELLED, WAIT_DEPENDENCIES)) - self.env["queue.job"].invalidate_model(["state"]) + """Cancel the jobs waiting on this one, and their own dependents + + A dependent job can no longer run once one of its dependencies is + cancelled, whatever the state of the others. + """ + dependents = self.db_record().dependent_ids + while dependents: + dependents = dependents.filtered( + lambda dependent: dependent.state == WAIT_DEPENDENCIES + ) + dependents.write( + { + "state": CANCELLED, + "date_cancelled": self.date_cancelled, + "result": self.env._( + "Cancelled because a job it depends on was cancelled" + ), + } + ) + dependents = dependents.dependent_ids def store(self): """Store the Job""" @@ -688,6 +712,24 @@ def env(self): def _env(self, env): self.recordset = self.recordset.with_env(env) + @property + def args(self): + """Positional arguments, rebound to the job's current cursor.""" + return _rebind_to_cr(self._args, self.env.cr) + + @args.setter + def args(self, value): + self._args = value + + @property + def kwargs(self): + """Keyword arguments, rebound to the job's current cursor.""" + return _rebind_to_cr(self._kwargs, self.env.cr) + + @kwargs.setter + def kwargs(self, value): + self._kwargs = value + @property def func(self): recordset = self.recordset.with_context(job_uuid=self.uuid) @@ -700,9 +742,8 @@ def job_function_name(self): @property def identity_key(self): - if self._identity_key is None: - if self._identity_key_func: - self._identity_key = self._identity_key_func(self) + if self._identity_key is None and self._identity_key_func: + self._identity_key = self._identity_key_func(self) return self._identity_key @identity_key.setter @@ -763,9 +804,9 @@ def eta(self, value): if not value: self._eta = None elif isinstance(value, timedelta): - self._eta = datetime.now() + value + self._eta = datetime.now() + value # noqa: DTZ005 elif isinstance(value, int): - self._eta = datetime.now() + timedelta(seconds=value) + self._eta = datetime.now() + timedelta(seconds=value) # noqa: DTZ005 else: self._eta = value @@ -800,13 +841,13 @@ def set_pending(self, result=None, reset_retry=True): def set_enqueued(self): self.state = ENQUEUED - self.date_enqueued = datetime.now() + self.date_enqueued = datetime.now() # noqa: DTZ005 self.date_started = None self.worker_pid = None def set_started(self): self.state = STARTED - self.date_started = datetime.now() + self.date_started = datetime.now() # noqa: DTZ005 self.worker_pid = os.getpid() self.add_lock_record() @@ -814,13 +855,13 @@ def set_done(self, result=None): self.state = DONE self.exc_name = None self.exc_info = None - self.date_done = datetime.now() + self.date_done = datetime.now() # noqa: DTZ005 if result is not None: self.result = result def set_cancelled(self, result=None): self.state = CANCELLED - self.date_cancelled = datetime.now() + self.date_cancelled = datetime.now() # noqa: DTZ005 if result is not None: self.result = result @@ -830,6 +871,13 @@ def set_failed(self, **kw): if v is not None: setattr(self, k, v) + def on_fail(self, fail_vals): + if not self.on_fail_method_name: + return + on_fail_func = getattr(self.recordset, self.on_fail_method_name, None) + if on_fail_func: + on_fail_func(**fail_vals) + def __repr__(self): return f"" @@ -873,7 +921,7 @@ def related_action(self): if not funcname: funcname = record._default_related_action if not isinstance(funcname, str): - raise ValueError( + raise ValueError( # noqa: TRY004 "related_action must be the name of the method on queue.job as string" ) action = getattr(record, funcname) diff --git a/queue_job/jobrunner/__init__.py b/queue_job/jobrunner/__init__.py index 50dd45e39d..c83c56b910 100644 --- a/queue_job/jobrunner/__init__.py +++ b/queue_job/jobrunner/__init__.py @@ -4,7 +4,6 @@ import logging from threading import Thread -import time from configparser import ConfigParser from odoo.service import server @@ -30,7 +29,7 @@ queue_job_config = dict(cp["queue_job"]) -from .runner import QueueJobRunner, _channels # noqa: E402 +from .runner import QueueJobRunner, _channels _logger = logging.getLogger(__name__) @@ -50,7 +49,7 @@ def __init__(self): def run(self): # sleep a bit to let the workers start at ease - time.sleep(START_DELAY) + self.runner.sleep(START_DELAY) self.runner.run() def stop(self): @@ -80,7 +79,7 @@ def process_work(self): self.runner = QueueJobRunner.from_environ_or_config() self._recover = False _logger.debug("WorkerJobRunner (%s) starting up", self.pid) - time.sleep(START_DELAY) + self.runner.sleep(START_DELAY) self.runner.run() def signal_time_expired_handler(self, n, stack): @@ -151,7 +150,8 @@ def prefork_worker_pop(server, pid): def threaded_start(server, *args, **kwargs): res = orig_threaded_start(server, *args, **kwargs) - _start_runner_thread("threaded server") + if not kwargs.get("stop"): + _start_runner_thread("threaded server") return res diff --git a/queue_job/jobrunner/channels.py b/queue_job/jobrunner/channels.py index bfc8984862..4f29e85acd 100644 --- a/queue_job/jobrunner/channels.py +++ b/queue_job/jobrunner/channels.py @@ -179,7 +179,7 @@ class ChannelJob: """ - __slots__ = ("db_name", "channel", "uuid", "_sorting_key", "__weakref__") + __slots__ = ("db_name", "channel", "uuid", "_sorting_key", "__weakref__") # noqa: RUF023 def __init__(self, db_name, channel, uuid, seq, date_created, priority, eta): self.db_name = db_name @@ -402,9 +402,14 @@ class Channel: with a capacity of 1. It is also possible to dedicate a channel with a limited capacity for application-autocreated subchannels without risking to overflow the system. + + A paused channel does not process any job until it is resumed. All subchannels + are blocked with their parent channel. """ - def __init__(self, name, parent, capacity=None, sequential=False, throttle=0): + def __init__( + self, name, parent, capacity=None, sequential=False, throttle=0, paused=False + ): self.name = name self.parent = parent if self.parent: @@ -417,6 +422,7 @@ def __init__(self, name, parent, capacity=None, sequential=False, throttle=0): self.capacity = capacity self.throttle = throttle # seconds self.sequential = sequential + self.paused = paused @property def sequential(self): @@ -434,11 +440,13 @@ def configure(self, config): * capacity * sequential * throttle + * paused """ assert self.fullname.endswith(config["name"]) self.capacity = config.get("capacity", None) self.sequential = bool(config.get("sequential", False)) self.throttle = int(config.get("throttle", 0)) + self.paused = bool(config.get("paused", False)) if self.sequential and self.capacity != 1: raise ValueError("A sequential channel must have a capacity of 1") @@ -455,9 +463,10 @@ def get_subchannel_by_name(self, subchannel_name): def __str__(self): capacity = "∞" if self.capacity is None else str(self.capacity) + paused = ",paused" if self.paused else "" return ( f"{self.fullname}(C:{capacity},Q:{len(self._queue)}," - f"R:{len(self._running)},F:{len(self._failed)})" + f"R:{len(self._running)},F:{len(self._failed)}{paused})" ) def remove(self, job): @@ -514,6 +523,8 @@ def set_failed(self, job): _logger.debug("job %s marked failed in channel %s", job.uuid, self) def has_capacity(self): + if self.paused: + return False if self.sequential and self._failed: # a sequential queue blocks on failed jobs return False @@ -796,6 +807,31 @@ class ChannelManager: >>> cm.notify(db, 'S', 'S3', 3, 0, 10, None, 'done') >>> pp(list(cm.get_jobs_to_run(now=105))) [] + + Test pausing a channel + + >>> cm = ChannelManager() + >>> cm.simple_configure('root:4,P:2:paused,P.sub:1') + >>> cm.notify(db, 'P', 'P1', 1, 0, 10, None, 'pending') + >>> cm.notify(db, 'P.sub', 'PS1', 2, 0, 10, None, 'pending') + + Paused channel yields no job + + >>> pp(list(cm.get_jobs_to_run(now=100))) + [] + + Resuming the channel yields the pending jobs + + >>> cm.simple_configure('root:4,P:2') + >>> pp(list(cm.get_jobs_to_run(now=100))) + [, ] + + Pausing the root channel blocks everything + + >>> cm.simple_configure('root:4:paused') + >>> cm.notify(db, 'P', 'P3', 4, 0, 10, None, 'pending') + >>> pp(list(cm.get_jobs_to_run(now=106))) + [] """ def __init__(self): diff --git a/queue_job/jobrunner/runner.py b/queue_job/jobrunner/runner.py index 925e015a6a..79ccf8a787 100644 --- a/queue_job/jobrunner/runner.py +++ b/queue_job/jobrunner/runner.py @@ -73,7 +73,7 @@ def _odoo_now(): def _connection_info_for(db_name): - db_or_uri, connection_info = odoo.sql_db.connection_info_for(db_name) + _db_or_uri, connection_info = odoo.sql_db.connection_info_for(db_name) for p in ("host", "port", "user", "password"): cfg = os.environ.get( @@ -91,7 +91,7 @@ def _async_http_get(scheme, host, port, user, password, db_name, job_uuid): # if this was python3 I would be doing this with # asyncio, aiohttp and aiopg def urlopen(): - url = f"{scheme}://{host}:{port}/queue_job/runjob?db={db_name}&job_uuid={job_uuid}" + url = f"{scheme}://{host}:{port}/queue_job/runjob?job_uuid={job_uuid}" # pylint: disable=except-pass try: auth = None @@ -99,7 +99,9 @@ def urlopen(): auth = (user, password) # we are not interested in the result, so we set a short timeout # but not too short so we trap and log hard configuration errors - response = requests.get(url, timeout=1, auth=auth) + response = requests.get( + url, timeout=1, auth=auth, headers={"X-Odoo-Database": db_name} + ) # raise_for_status will result in either nothing, a Client Error # for HTTP Response codes between 400 and 500 or a Server Error @@ -138,7 +140,7 @@ def close(self): # del try: self.conn.close() - except Exception: + except Exception: # noqa: BLE001, S110 pass self.conn = None @@ -334,6 +336,7 @@ def __init__( self.channel_manager.simple_configure(channel_config_string) self.db_by_name = {} self._stop = False + self._stop_event = threading.Event() self._stop_pipe = os.pipe() def __del__(self): @@ -473,7 +476,7 @@ def wait_notification(self): # if timeout remains a large negative number, it is most # probably a bug _logger.debug("select() timeout: %.2f sec", timeout) - if timeout > 0: + if timeout > 0: # noqa: SIM102 if conns and not self._stop: with select() as sel: for conn in conns: @@ -485,9 +488,18 @@ def wait_notification(self): continue key.fileobj.poll() + def sleep(self, seconds): + """Wait for ``seconds``, or less if :meth:`stop` is called meanwhile. + + A plain ``time.sleep`` would hold the thread, and so the server + shutdown that joins it, for up to the whole delay. + """ + self._stop_event.wait(seconds) + def stop(self): _logger.info("graceful stop requested") self._stop = True + self._stop_event.set() # wakeup the select() in wait_notification os.write(self._stop_pipe[1], b".") @@ -519,12 +531,12 @@ def run(self): ERROR_RECOVERY_DELAY, ) self.close_databases() - time.sleep(ERROR_RECOVERY_DELAY) + self.sleep(ERROR_RECOVERY_DELAY) except Exception: _logger.exception( "exception: sleeping %ds and retrying", ERROR_RECOVERY_DELAY ) self.close_databases() - time.sleep(ERROR_RECOVERY_DELAY) + self.sleep(ERROR_RECOVERY_DELAY) self.close_databases(remove_jobs=False) _logger.info("stopped") diff --git a/queue_job/migrations/19.0.2.2.0/pre-migration.py b/queue_job/migrations/19.0.2.2.0/pre-migration.py new file mode 100644 index 0000000000..a9150c45d7 --- /dev/null +++ b/queue_job/migrations/19.0.2.2.0/pre-migration.py @@ -0,0 +1,11 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + # Old jobs are now removed by the base autovacuum cron + openupgrade.delete_records_safely_by_xml_id( + env, + ["queue_job.ir_cron_autovacuum_queue_jobs"], + ) diff --git a/queue_job/migrations/20.0.2.4.0/pre-migration.py b/queue_job/migrations/20.0.2.4.0/pre-migration.py new file mode 100644 index 0000000000..cfc7fc1317 --- /dev/null +++ b/queue_job/migrations/20.0.2.4.0/pre-migration.py @@ -0,0 +1,13 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + # Databases already on the dhongu/queue 20.0 fork (20.0.2.0.x, before the + # alignment with OCA/queue 20.0) skip the 19.0.2.2.0 step: drop the old + # autovacuum cron here too, its model.autovacuum() method is gone. + openupgrade.delete_records_safely_by_xml_id( + env, + ["queue_job.ir_cron_autovacuum_queue_jobs"], + ) diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index 88b6b4e773..cc5fbf9ebd 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -4,10 +4,10 @@ import logging import random import time -from datetime import datetime, timedelta from odoo import api, exceptions, fields, models -from odoo.tools import config, html_escape +from odoo.fields import Domain +from odoo.tools import SQL, html_escape from odoo.tools.sql import create_index from odoo.addons.base_sparse_field.models.fields import Serialized @@ -35,7 +35,7 @@ class QueueJob(models.Model): _name = "queue.job" _description = "Queue Job" - _inherit = ["mail.thread", "mail.activity.mixin"] + _inherit = ["mail.thread", "mail.activity.mixin"] # noqa: RUF012 _log_access = False _order = "date_created DESC, date_done DESC" @@ -70,9 +70,7 @@ class QueueJob(models.Model): help="Single shared identifier of a Graph. Empty for a single job.", ) user_id = fields.Many2one(comodel_name="res.users", string="User ID") - company_id = fields.Many2one( - comodel_name="res.company", string="Company", index=True - ) + company_id = fields.Many2one(comodel_name="res.company", index=True) name = fields.Char(string="Description", readonly=True) model_name = fields.Char(string="Model", readonly=True) @@ -83,6 +81,20 @@ class QueueJob(models.Model): base_type=models.BaseModel, ) dependencies = Serialized(readonly=True) + dependency_ids = fields.Many2many( + comodel_name="queue.job", + compute="_compute_dependency_ids", + search="_search_dependency_ids", + string="Dependency Jobs", + help="Jobs this job depends on.", + ) + dependent_ids = fields.Many2many( + comodel_name="queue.job", + compute="_compute_dependency_ids", + search="_search_dependent_ids", + string="Dependent Jobs", + help="Jobs depending on this job.", + ) # dependency graph as expected by the field widget dependency_graph = Serialized(compute="_compute_dependency_graph") graph_jobs_count = fields.Integer(compute="_compute_graph_jobs_count") @@ -121,7 +133,6 @@ class QueueJob(models.Model): channel_method_name = fields.Char(string="Complete Method Name", readonly=True) job_function_id = fields.Many2one( comodel_name="queue.job.function", - string="Job Function", readonly=True, ) @@ -144,7 +155,7 @@ def init(self): ), comment=("Queue Job: partial index for identity_key on active states"), ) - # Used by .autovacuum + # Used by ._gc_old_jobs create_index( cr, "queue_job_channel_date_done_date_created_index", @@ -153,6 +164,55 @@ def init(self): comment="Queue Job: index to accelerate autovacuum", ) + @api.depends("dependencies") + def _compute_dependency_ids(self): + uuids = set() + for record in self: + dependencies = record.dependencies or {} + uuids.update(dependencies.get("depends_on", [])) + uuids.update(dependencies.get("reverse_depends_on", [])) + jobs = self.search([("uuid", "in", list(uuids))]) + jobs_by_uuid = jobs.grouped("uuid") + for record in self: + dependencies = record.dependencies or {} + record.dependency_ids = self.browse().concat( + jobs_by_uuid.get(uuid, self.browse()) + for uuid in dependencies.get("depends_on", []) + ) + record.dependent_ids = self.browse().concat( + jobs_by_uuid.get(uuid, self.browse()) + for uuid in dependencies.get("reverse_depends_on", []) + ) + + def _search_dependency_ids(self, operator, value): + return self._search_dependencies("depends_on", operator, value) + + def _search_dependent_ids(self, operator, value): + return self._search_dependencies("reverse_depends_on", operator, value) + + def _search_dependencies(self, key, operator, value): + """Search the jobs having one of the given jobs in ``dependencies[key]``""" + if operator == "in": + operator, value = "any", Domain("id", "in", value) + if operator != "any": + return NotImplemented + jobs = self._search(value) + return Domain.custom( + to_sql=lambda table: SQL( + """ + EXISTS ( + SELECT 1 + FROM json_array_elements_text(%s::json -> %s) AS dep(uuid) + JOIN queue_job AS dep_job ON dep_job.uuid = dep.uuid + WHERE dep_job.id IN %s + ) + """, + table.dependencies, + key, + jobs.subselect(), + ) + ) + @api.depends("dependencies") def _compute_dependency_graph(self): graph_uuids = [uuid for uuid in self.mapped("graph_uuid") if uuid] @@ -342,8 +402,11 @@ def button_cancelled(self): # If job was set to DONE do not cancel it states_from = (WAIT_DEPENDENCIES, PENDING, ENQUEUED, FAILED) result = self.env._("Cancelled by %s", self.env.user.name) - records = self.filtered(lambda job_: job_.state in states_from) - records._change_job_state(CANCELLED, result=result) + for record in self: + # Cancelling a job also cancels its dependents, some of them may + # be in self already + if record.state in states_from: + record._change_job_state(CANCELLED, result=result) return True def requeue(self): @@ -374,7 +437,7 @@ def _subscribe_users_domain(self): if not group: return None companies = self.mapped("company_id") - domain = [("group_ids", "=", group.id)] + domain = [("all_group_ids", "in", group.ids)] if companies: domain.append(("company_id", "in", companies.ids)) return domain @@ -408,33 +471,41 @@ def _needaction_domain_get(self): """ return [("state", "=", "failed")] - def autovacuum(self): - """Delete all jobs done based on the removal interval defined on the - channel + @api.autovacuum + def _gc_old_jobs(self): + """Delete the jobs done or cancelled before the removal interval of + their channel, in batches of 1000. - Called from a cron. + Jobs of an unknown channel (renamed, deleted) use the removal interval + of the root channel. + + Called from the base autovacuum cron, which commits after each batch + and calls it again while it returns remaining jobs. """ - for channel in self.env["queue.job.channel"].search([]): # pylint: disable=no-search-all - deadline = datetime.now() - timedelta(days=int(channel.removal_interval)) - # Delete in chunks using a stable order (matches composite index) - while True: - jobs = self.search( - [ - "|", - ("date_done", "<=", deadline), - ("date_cancelled", "<=", deadline), - ("channel", "=", channel.complete_name), - ], - order="date_done, date_created", - limit=1000, - ) - if jobs: - jobs.sudo().unlink() - if not config["test_enable"]: - self.env.cr.commit() # pylint: disable=E8102 - else: - break - return True + channels = self.env["queue.job.channel"].search([]) # pylint: disable=no-search-all + root = self.env.ref("queue_job.channel_root") + intervals = [ + (Domain("channel", "=", channel.complete_name), channel.removal_interval) + for channel in channels + ] + intervals.append( + ( + Domain("channel", "not in", channels.mapped("complete_name")), + root.removal_interval, + ) + ) + domain = Domain.OR( + channel_domain + & ( + Domain("date_done", "<=", f"-{days}d") + | Domain("date_cancelled", "<=", f"-{days}d") + ) + for channel_domain, days in intervals + ) + limit = 1000 + jobs = self.search(domain, order="date_done, date_created", limit=limit + 1) + jobs[:limit].sudo().unlink() + return len(jobs[:limit]), len(jobs) > limit def related_action_open_record(self): """Open a form view with the record(s) of the job. @@ -490,3 +561,6 @@ def _test_job( time.sleep(job_duration) if commit_within_job: self.env.cr.commit() # pylint: disable=invalid-commit + + def _test_on_fail(self, **kw): + pass diff --git a/queue_job/models/queue_job_channel.py b/queue_job/models/queue_job_channel.py index 0a5c1c917b..ee5f7588fe 100644 --- a/queue_job/models/queue_job_channel.py +++ b/queue_job/models/queue_job_channel.py @@ -37,7 +37,7 @@ def _compute_complete_name(self): if not record.name: complete_name = "" # new record elif record.parent_id: - complete_name = ".".join([record.parent_id.complete_name, record.name]) + complete_name = f"{record.parent_id.complete_name}.{record.name}" else: complete_name = record.name record.complete_name = complete_name diff --git a/queue_job/models/queue_job_function.py b/queue_job/models/queue_job_function.py index fc4c70e7cf..d574753593 100644 --- a/queue_job/models/queue_job_function.py +++ b/queue_job/models/queue_job_function.py @@ -29,7 +29,8 @@ class QueueJobFunction(models.Model): "related_action_func_name " "related_action_kwargs " "job_function_id " - "allow_commit", + "allow_commit " + "on_fail_method_name", ) def _default_channel(self): @@ -44,14 +45,15 @@ def _default_channel(self): # model and method should be required, but the required flag doesn't # let a chance to _inverse_name to be executed - model_id = fields.Many2one( - comodel_name="ir.model", string="Model", ondelete="cascade" - ) + model_id = fields.Many2one(comodel_name="ir.model", ondelete="cascade") method = fields.Char() + on_fail_method = fields.Char( + help="Model function to be called if the job is failed and will not be " + "retried.", + ) channel_id = fields.Many2one( comodel_name="queue.job.channel", - string="Channel", required=True, default=lambda r: r._default_channel(), ) @@ -159,6 +161,7 @@ def job_default_config(self): related_action_kwargs={}, job_function_id=None, allow_commit=False, + on_fail_method_name=None, ) def _parse_retry_pattern(self): @@ -195,6 +198,7 @@ def job_config(self, name): related_action_kwargs=config.related_action.get("kwargs", {}), job_function_id=config.id, allow_commit=config.allow_commit, + on_fail_method_name=config.on_fail_method, ) def _retry_pattern_format_error_message(self): diff --git a/queue_job/post_load.py b/queue_job/post_load.py deleted file mode 100644 index 44ba8d7ae3..0000000000 --- a/queue_job/post_load.py +++ /dev/null @@ -1,26 +0,0 @@ -import logging - -from odoo.http import router - -_logger = logging.getLogger(__name__) - - -def post_load(): - _logger.info( - "Apply odoo.http.router._set_session_and_dbname monkey patch to capture db" - " from request with multiple databases" - ) - _set_session_and_dbname_orig = router._set_session_and_dbname - - def _set_session_and_dbname(request): - _set_session_and_dbname_orig(request) - if ( - not request.db - and request.httprequest.path == "/queue_job/runjob" - and request.httprequest.args.get("db") - ): - request.db = request.httprequest.args["db"] - - # Application.__call__ and retrying.py resolve the function through the - # router module at call time, so patching the module attribute is enough. - router._set_session_and_dbname = _set_session_and_dbname diff --git a/queue_job/security/security.xml b/queue_job/security/security.xml index 2b5f9da5e4..b4bf2549e9 100644 --- a/queue_job/security/security.xml +++ b/queue_job/security/security.xml @@ -1,12 +1,12 @@ - + - + Job Queue - 50 + - + Job Queue - 20 + Job Queue Manager diff --git a/queue_job/static/description/index.html b/queue_job/static/description/index.html index b4a45121fd..9bd5214cb1 100644 --- a/queue_job/static/description/index.html +++ b/queue_job/static/description/index.html @@ -372,7 +372,7 @@

Job Queue

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:9310ffeb8c7cc9466fe499b49ab3d7f8da8bd13d2dd9a3f6cc3f3b2fa2f852e3 +!! source digest: sha256:8fe930e0d2082bf352442794a848d2931d0f853a2f5e1b0d066f10d4c68fb33f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Mature License: LGPL-3 OCA/queue Translate me on Weblate Try me on Runboat

This addon adds an integrated Job Queue to Odoo.

diff --git a/queue_job/static/src/views/fields/job_direct_graph/job_direct_graph.esm.js b/queue_job/static/src/views/fields/job_direct_graph/job_direct_graph.esm.js index dcad3f9bf2..35bc69fa54 100644 --- a/queue_job/static/src/views/fields/job_direct_graph/job_direct_graph.esm.js +++ b/queue_job/static/src/views/fields/job_direct_graph/job_direct_graph.esm.js @@ -158,7 +158,7 @@ class JobDirectGraph extends Component { async openDependencyJob(resId) { const action = await this.orm.call( this.model, - "get_formview_action", + "get_record_default_action", [[resId]], { context: this.context, diff --git a/queue_job/tests/__init__.py b/queue_job/tests/__init__.py index 16bcdff96b..a31cc36f8e 100644 --- a/queue_job/tests/__init__.py +++ b/queue_job/tests/__init__.py @@ -1,4 +1,5 @@ -from . import test_run_rob_controller +from . import test_run_job_controller_http +from . import test_run_job_controller from . import test_runner_channels from . import test_runner_runner from . import test_delayable @@ -7,4 +8,5 @@ from . import test_model_job_channel from . import test_model_job_function from . import test_queue_job_protected_write +from . import test_subscribe_users_domain from . import test_wizards diff --git a/queue_job/tests/common.py b/queue_job/tests/common.py index f74e4ad651..1499714e17 100644 --- a/queue_job/tests/common.py +++ b/queue_job/tests/common.py @@ -92,13 +92,15 @@ def button_that_uses_delayable_chain(self): # to the database) jobs_tester.perform_enqueued_jobs() """ - with mock.patch( - "odoo.addons.queue_job.delay.Job", - name="Job Class", - unsafe=True, - ) as job_cls_mock: - with JobsTrap(job_cls_mock) as trap: - yield trap + with ( + mock.patch( + "odoo.addons.queue_job.delay.Job", + name="Job Class", + unsafe=True, + ) as job_cls_mock, + JobsTrap(job_cls_mock) as trap, + ): + yield trap class JobCall(typing.NamedTuple): diff --git a/queue_job/tests/test_delayable_split.py b/queue_job/tests/test_delayable_split.py index 25fd9c3ebc..321801bcc4 100644 --- a/queue_job/tests/test_delayable_split.py +++ b/queue_job/tests/test_delayable_split.py @@ -43,7 +43,7 @@ def test_delayable_split_10_3(self): dl.method("arg", kwarg="kwarg") group = dl.split(3) self.assertEqual(len(group._delayables), 4) - delayables = sorted(list(group._delayables), key=lambda x: x.description) + delayables = sorted(group._delayables, key=lambda x: x.description) self.assertEqual(delayables[0].recordset, self.FakeRecordSet([0, 1, 2])) self.assertEqual(delayables[1].recordset, self.FakeRecordSet([3, 4, 5])) self.assertEqual(delayables[2].recordset, self.FakeRecordSet([6, 7, 8])) @@ -75,7 +75,7 @@ def test_delayable_split_10_5(self): dl.method("arg", kwarg="kwarg") group = dl.split(5) self.assertEqual(len(group._delayables), 2) - delayables = sorted(list(group._delayables), key=lambda x: x.description) + delayables = sorted(group._delayables, key=lambda x: x.description) self.assertEqual(delayables[0].recordset, self.FakeRecordSet([0, 1, 2, 3, 4])) self.assertEqual(delayables[1].recordset, self.FakeRecordSet([5, 6, 7, 8, 9])) self.assertEqual(delayables[0].description, "Method to be called (split 1/2)") @@ -87,7 +87,7 @@ def test_delayable_split_10_10(self): dl.method("arg", kwarg="kwarg") group = dl.split(10) self.assertEqual(len(group._delayables), 1) - delayables = sorted(list(group._delayables), key=lambda x: x.description) + delayables = sorted(group._delayables, key=lambda x: x.description) self.assertEqual(delayables[0].recordset, self.FakeRecordSet(range(10))) self.assertEqual(delayables[0].description, "Method to be called (split 1/1)") self._cancel_delayables(*group._delayables) @@ -97,7 +97,7 @@ def test_delayable_split_10_20(self): dl.method("arg", kwarg="kwarg") group = dl.split(20) self.assertEqual(len(group._delayables), 1) - delayables = sorted(list(group._delayables), key=lambda x: x.description) + delayables = sorted(group._delayables, key=lambda x: x.description) self.assertEqual(delayables[0].recordset, self.FakeRecordSet(range(10))) self.assertEqual(delayables[0].description, "Method to be called (split 1/1)") self._cancel_delayables(*group._delayables) diff --git a/queue_job/tests/test_json_field.py b/queue_job/tests/test_json_field.py index 23974e23c9..fda6b9eb7a 100644 --- a/queue_job/tests/test_json_field.py +++ b/queue_job/tests/test_json_field.py @@ -11,7 +11,7 @@ # pylint: disable=odoo-addons-relative-import # we are testing, we want to test as we were an external consumer of the API -from odoo.addons.queue_job.fields import JobDecoder, JobEncoder +from odoo.addons.queue_job.fields import JobDecoder, JobEncoder, JobSerialized class TestJson(common.TransactionCase): @@ -141,7 +141,7 @@ def test_decoder_recordset_list_without_user(self): self.assertEqual(value, expected) def test_encoder_datetime(self): - value = ["a", 1, datetime(2017, 4, 19, 8, 48, 50, 1)] + value = ["a", 1, datetime(2017, 4, 19, 8, 48, 50, 1)] # noqa: DTZ001 value_json = json.dumps(value, cls=JobEncoder) expected = [ "a", @@ -155,7 +155,7 @@ def test_decoder_datetime(self): '["a", 1, {"_type": "datetime_isoformat",' '"value": "2017-04-19T08:48:50.000001"}]' ) - expected = ["a", 1, datetime(2017, 4, 19, 8, 48, 50, 1)] + expected = ["a", 1, datetime(2017, 4, 19, 8, 48, 50, 1)] # noqa: DTZ001 value = json.loads(value_json, cls=JobDecoder, env=self.env) self.assertEqual(value, expected) @@ -195,3 +195,9 @@ def test_decoder_etree(self): value = json.loads(value_json, cls=JobDecoder, env=self.env) value[2] = etree.tostring(value[2]) self.assertEqual(value, expected) + + def test_job_serialized_base_type_is_validated(self): + model_class = type(self.env["queue.job"]) + JobSerialized(base_type=dict)._setup_attrs__(model_class, "supported") + with self.assertRaisesRegex(ValueError, "is not a supported base type"): + JobSerialized(base_type=int)._setup_attrs__(model_class, "unsupported") diff --git a/queue_job/tests/test_model_job_function.py b/queue_job/tests/test_model_job_function.py index 9095f2a55e..b835c3c4ee 100644 --- a/queue_job/tests/test_model_job_function.py +++ b/queue_job/tests/test_model_job_function.py @@ -35,6 +35,7 @@ def test_function_job_config(self): { "model_id": self.env.ref("base.model_res_users").id, "method": "read", + "on_fail_method": "search_read", "channel_id": channel.id, "edit_retry_pattern": "{1: 2, 3: 4}", "edit_related_action": ( @@ -55,5 +56,6 @@ def test_function_job_config(self): related_action_kwargs={"b": 1}, job_function_id=job_function.id, allow_commit=True, + on_fail_method_name="search_read", ), ) diff --git a/queue_job/tests/test_run_job_controller.py b/queue_job/tests/test_run_job_controller.py new file mode 100644 index 0000000000..4090c811ea --- /dev/null +++ b/queue_job/tests/test_run_job_controller.py @@ -0,0 +1,109 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from contextlib import closing +from unittest.mock import patch + +from odoo.tests.common import TransactionCase +from odoo.tools import mute_logger + +from ..controllers.main import RunJobController +from ..exception import JobError +from ..job import Job + + +class TestRunJobController(TransactionCase): + def setUp(self): + super().setUp() + + def _clean_queue_job(): + self.env["queue.job"].search([]).unlink() + + self.addCleanup(_clean_queue_job) + + def test_get_failure_values(self): + method = self.env["res.users"].mapped + job = Job(method) + ctrl = RunJobController() + rslt = ctrl._get_failure_values(job, "info", Exception("zero", "one")) + self.assertEqual( + rslt, {"exc_info": "info", "exc_name": "Exception", "exc_message": "zero"} + ) + + def test_runjob_success(self): + job = self.env["queue.job"].with_delay()._test_job() + RunJobController._runjob(self.env, job) + self.assertEqual(job.state, "done") + self.assertEqual(job.db_record().state, "done") + + def test_runjob_on_fail(self): + function = self.env.ref("queue_job.job_function_queue_job__test_job") + function.on_fail_method = "_test_on_fail" + job = self.env["queue.job"].with_delay()._test_job(failure_rate=1) + with ( + self.assertRaises(JobError), + patch( + "odoo.addons.queue_job.models.queue_job.QueueJob._test_on_fail" + ) as mocked_hook, + patch("odoo.addons.queue_job.job.Job.in_temporary_env") as mocked_temp_env, + mute_logger("odoo.addons.queue_job.controllers.main"), + ): + mocked_temp_env.return_value.__enter__.return_value = self.env + RunJobController._runjob(self.env, job) + self.assertEqual(job.state, "failed") + self.assertEqual(mocked_hook.call_count, 1) + + @mute_logger("odoo.addons.queue_job.controllers.main") + def test_runjob_on_fail_no_deadlock(self): + """The on fail hook can write on the records the failed job wrote. + + The hook runs on another cursor, while the failed job's transaction + is still open. Without rolling back the job's changes first, the hook + waits for the job's lock, which is only released after the hook. + """ + function = self.env.ref("queue_job.job_function_queue_job__test_job") + function.on_fail_method = "_test_on_fail" + # Use a committed record, so that the other cursor can see it + partner = self.env.ref("base.partner_admin") + job = self.env["queue.job"].with_delay()._test_job() + + # The job writes on the partner (locking it), then fails + def failing_job(): + partner.name = "Written by job" + partner.flush_recordset() + raise JobError("Job failed") + + # The hook writes on the same partner from another cursor. Its changes + # are rolled back on close, and the lock timeout avoids waiting forever. + def on_fail(**kwargs): + with closing(self.registry.cursor()) as other_cr: + other_cr.execute("SET LOCAL lock_timeout = '2s'") + other_cr.execute( + "UPDATE res_partner SET name = 'Written by hook' WHERE id = %s", + [partner.id], + ) + + with ( + self.assertRaises(JobError), + patch( + "odoo.addons.queue_job.models.queue_job.QueueJob._test_job", + side_effect=failing_job, + ), + patch( + "odoo.addons.queue_job.models.queue_job.QueueJob._test_on_fail", + side_effect=on_fail, + ) as mocked_hook, + patch("odoo.addons.queue_job.job.Job.in_temporary_env") as mocked_temp_env, + ): + mocked_temp_env.return_value.__enter__.return_value = self.env + RunJobController._runjob(self.env, job) + self.assertEqual(mocked_hook.call_count, 1) + + def test_runjob_on_fail_not_configured(self): + job = self.env["queue.job"].with_delay()._test_job(failure_rate=1) + with ( + self.assertRaises(JobError), + patch("odoo.addons.queue_job.job.Job.in_temporary_env") as mocked_temp_env, + mute_logger("odoo.addons.queue_job.controllers.main"), + ): + mocked_temp_env.return_value.__enter__.return_value = self.env + RunJobController._runjob(self.env, job) + self.assertEqual(job.state, "failed") diff --git a/queue_job/tests/test_run_job_controller_http.py b/queue_job/tests/test_run_job_controller_http.py new file mode 100644 index 0000000000..3bd660d485 --- /dev/null +++ b/queue_job/tests/test_run_job_controller_http.py @@ -0,0 +1,85 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). + +from unittest import mock + +from odoo import SUPERUSER_ID +from odoo.http.requestlib import Request +from odoo.tests.common import HttpCase, tagged + +from ..controllers.main import RunJobController + + +@tagged("-at_install", "post_install") +class TestRunJobHttp(HttpCase): + """End-to-end tests for the ``/queue_job/runjob`` endpoint. + + ``runjob`` is declared ``auth="none"``, so ``_auth_method_none`` pins + ``transaction.default_env`` to an env with ``uid=None``. The controller + must additionally repoint ``default_env`` to a superuser env, otherwise + any flush during ``job.perform()`` that goes through + ``Transaction.flush() -> default_env.flush_all()`` recomputes stored + fields with ``self.env.user`` as an empty recordset. See #922. + """ + + def _capture_default_env_uid_at_acquire(self): + """Hit ``/queue_job/runjob`` and observe ``transaction.default_env.uid`` + at the moment ``_acquire_job`` is entered. + + ``_acquire_job`` is patched to return ``None`` so the endpoint exits + without performing the job. This avoids the commit inside + ``_acquire_job``, which is forbidden inside tests, and is sufficient + to observe the env state established by the request-handling + machinery: nothing between ``update_env`` and ``_acquire_job`` + touches ``transaction.default_env``, so the value seen here is the + same value a job would see at ``perform()`` time. + + HttpCase runs the HTTP server in the same process, so class-level + ``mock.patch`` calls take effect on the server side as well. + """ + captured = {} + + def spy(cls, env, job_uuid): + captured["default_env_uid"] = env.transaction.default_env.uid + + with mock.patch.object(RunJobController, "_acquire_job", classmethod(spy)): + response = self.url_open( + f"/queue_job/runjob?db={self.env.cr.dbname}&job_uuid=stub" + ) + response.raise_for_status() + + return captured.get("default_env_uid") + + def test_runjob_pins_default_env_to_superuser(self): + """``runjob`` must set ``transaction.default_env`` to a superuser env. + + Verifies that by the time ``_acquire_job`` is entered, + ``env.transaction.default_env.uid`` is ``SUPERUSER_ID``. This is the + state that lets flushes triggered by the job recompute stored fields + with a real ``self.env.user`` rather than an empty recordset. + """ + default_env_uid = self._capture_default_env_uid_at_acquire() + self.assertEqual(default_env_uid, SUPERUSER_ID) + + def test_runjob_without_updating_default_env_leaves_uid_none(self): + """Repointing ``default_env`` is the specific mechanism this relies on. + + Neutralises ``http.request.update_env`` for the duration of the + request, matching what happens if a ``runjob`` implementation only + obtains a local superuser env via ``http.request.env(user=...)`` + without invoking ``update_env``. The observable ``default_env.uid`` + then remains at the ``None`` value installed by + ``_auth_method_none``. This isolates ``default_env`` repointing as + the load-bearing behavior of ``runjob``: any future refactor that + drops it will trip this test. + """ + + def no_op_update_env(self_, user=None, context=None, su=None): + """Alternative ``Request.update_env`` that intentionally does + nothing. Simulates a controller that never asks the request to + update its environment. + """ + + with mock.patch.object(Request, "update_env", no_op_update_env): + default_env_uid = self._capture_default_env_uid_at_acquire() + + self.assertIsNone(default_env_uid) diff --git a/queue_job/tests/test_run_rob_controller.py b/queue_job/tests/test_run_rob_controller.py deleted file mode 100644 index 1a15f4363a..0000000000 --- a/queue_job/tests/test_run_rob_controller.py +++ /dev/null @@ -1,23 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - -from odoo.tests.common import TransactionCase - -from ..controllers.main import RunJobController -from ..job import Job - - -class TestRunJobController(TransactionCase): - def test_get_failure_values(self): - method = self.env["res.users"].mapped - job = Job(method) - ctrl = RunJobController() - rslt = ctrl._get_failure_values(job, "info", Exception("zero", "one")) - self.assertEqual( - rslt, {"exc_info": "info", "exc_name": "Exception", "exc_message": "zero"} - ) - - def test_runjob_success(self): - job = self.env["queue.job"].with_delay()._test_job() - RunJobController._runjob(self.env, job) - self.assertEqual(job.state, "done") - self.assertEqual(job.db_record().state, "done") diff --git a/queue_job/tests/test_runner_runner.py b/queue_job/tests/test_runner_runner.py index 131ce6322d..2adbf610db 100644 --- a/queue_job/tests/test_runner_runner.py +++ b/queue_job/tests/test_runner_runner.py @@ -4,10 +4,12 @@ # pylint: disable=odoo-addons-relative-import # we are testing, we want to test as we were an external consumer of the API import os +import threading +from unittest.mock import patch from odoo.tests import BaseCase, tagged -from odoo.addons.queue_job.jobrunner import runner +from odoo.addons.queue_job.jobrunner import START_DELAY, QueueJobRunnerThread, runner from .common import load_doctests @@ -57,3 +59,35 @@ def test_runner_file_closed_write_descriptor(self): self.assertFalse(self._is_open_file_descriptor(read_fd)) self.assertFalse(self._is_open_file_descriptor(write_fd)) + + def test_runner_stop_interrupts_the_recovery_delay(self): + """A runner that lost the master election stops without sleeping it out. + + The server joins the runner thread on shutdown, so a stop waiting for + ERROR_RECOVERY_DELAY held the whole process for up to 5 seconds. + """ + a_runner = runner.QueueJobRunner.from_environ_or_config() + election_lost = threading.Event() + + def initialize_databases(): + election_lost.set() + raise runner.MasterElectionLost("held by another runner") + + with patch.object( + a_runner, "initialize_databases", side_effect=initialize_databases + ): + thread = threading.Thread(target=a_runner.run, daemon=True) + thread.start() + self.addCleanup(thread.join) + self.assertTrue(election_lost.wait(timeout=5)) + a_runner.stop() + thread.join(timeout=runner.ERROR_RECOVERY_DELAY / 2) + self.assertFalse(thread.is_alive()) + + def test_runner_thread_stop_interrupts_the_start_delay(self): + thread = QueueJobRunnerThread() + thread.start() + self.addCleanup(thread.join) + thread.stop() + thread.join(timeout=START_DELAY / 2) + self.assertFalse(thread.is_alive()) diff --git a/queue_job/tests/test_subscribe_users_domain.py b/queue_job/tests/test_subscribe_users_domain.py new file mode 100644 index 0000000000..fa13c834cd --- /dev/null +++ b/queue_job/tests/test_subscribe_users_domain.py @@ -0,0 +1,39 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo import Command +from odoo.tests import common + + +class TestSubscribeUsersDomain(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + group_user = cls.env.ref("base.group_user") + manager_group = cls.env.ref("queue_job.group_queue_job_manager") + implying_group = cls.env["res.groups"].create( + { + "name": "Implies Job Queue Manager", + "implied_ids": [Command.link(manager_group.id)], + } + ) + Users = cls.env["res.users"] + cls.direct_manager = Users.create( + { + "name": "Direct Queue Manager", + "login": "queue_direct_manager", + "group_ids": [Command.set([group_user.id, manager_group.id])], + } + ) + cls.implied_manager = Users.create( + { + "name": "Implied Queue Manager", + "login": "queue_implied_manager", + "group_ids": [Command.set([group_user.id, implying_group.id])], + } + ) + + def test_subscribe_users_domain_includes_implied_managers(self): + domain = self.env["queue.job"]._subscribe_users_domain() + users = self.env["res.users"].search(domain) + self.assertIn(self.direct_manager, users) + self.assertIn(self.implied_manager, users) diff --git a/queue_job/utils.py b/queue_job/utils.py index 66b0430c3e..d037b8b530 100644 --- a/queue_job/utils.py +++ b/queue_job/utils.py @@ -4,6 +4,8 @@ import logging import os +from odoo import tools + _logger = logging.getLogger(__name__) @@ -17,5 +19,6 @@ def must_run_without_delay(env): return True if env.context.get("queue_job__no_delay"): - _logger.info("`queue_job__no_delay` ctx key found. NO JOB scheduled.") + if not tools.config["test_enable"]: + _logger.info("`queue_job__no_delay` ctx key found. NO JOB scheduled.") return True diff --git a/queue_job/views/queue_job_channel_views.xml b/queue_job/views/queue_job_channel_views.xml index 50c245716b..465196704c 100644 --- a/queue_job/views/queue_job_channel_views.xml +++ b/queue_job/views/queue_job_channel_views.xml @@ -1,4 +1,4 @@ - + queue.job.channel.form diff --git a/queue_job/views/queue_job_function_views.xml b/queue_job/views/queue_job_function_views.xml index ca481f5777..4667968ceb 100644 --- a/queue_job/views/queue_job_function_views.xml +++ b/queue_job/views/queue_job_function_views.xml @@ -1,4 +1,4 @@ - + queue.job.function.form diff --git a/queue_job/views/queue_job_menus.xml b/queue_job/views/queue_job_menus.xml index 8142605de9..86ea61592b 100644 --- a/queue_job/views/queue_job_menus.xml +++ b/queue_job/views/queue_job_menus.xml @@ -1,4 +1,4 @@ - + + queue.job.form diff --git a/queue_job/wizards/queue_jobs_to_cancelled_views.xml b/queue_job/wizards/queue_jobs_to_cancelled_views.xml index c501cf21b5..c4c05ad7f1 100644 --- a/queue_job/wizards/queue_jobs_to_cancelled_views.xml +++ b/queue_job/wizards/queue_jobs_to_cancelled_views.xml @@ -1,4 +1,4 @@ - + Cancel Jobs diff --git a/queue_job/wizards/queue_jobs_to_done_views.xml b/queue_job/wizards/queue_jobs_to_done_views.xml index 6bc6653327..5678ae7099 100644 --- a/queue_job/wizards/queue_jobs_to_done_views.xml +++ b/queue_job/wizards/queue_jobs_to_done_views.xml @@ -1,4 +1,4 @@ - + Set Jobs to Done diff --git a/queue_job/wizards/queue_requeue_job_views.xml b/queue_job/wizards/queue_requeue_job_views.xml index cfad7879c0..7836ed5274 100644 --- a/queue_job/wizards/queue_requeue_job_views.xml +++ b/queue_job/wizards/queue_requeue_job_views.xml @@ -1,4 +1,4 @@ - + Requeue Jobs diff --git a/queue_job_cron_jobrunner/__manifest__.py b/queue_job_cron_jobrunner/__manifest__.py index 071a2e9ae6..af6f708c3d 100644 --- a/queue_job_cron_jobrunner/__manifest__.py +++ b/queue_job_cron_jobrunner/__manifest__.py @@ -1,7 +1,7 @@ { "name": "Queue Job Cron Jobrunner", "summary": "Run jobs without a dedicated JobRunner", - "version": "20.0.1.0.1", + "version": "20.0.1.0.2", "development_status": "Alpha", "author": "Camptocamp SA, Odoo Community Association (OCA)", "maintainers": ["ivantodorovich"], diff --git a/queue_job_cron_jobrunner/models/queue_job.py b/queue_job_cron_jobrunner/models/queue_job.py index 7bbd3490ce..9abcbc7538 100644 --- a/queue_job_cron_jobrunner/models/queue_job.py +++ b/queue_job_cron_jobrunner/models/queue_job.py @@ -9,11 +9,9 @@ from psycopg2 import OperationalError from odoo import api, models +from odoo.sql_db import PG_CONCURRENCY_EXCEPTIONS_TO_RETRY -from odoo.addons.queue_job.controllers.main import ( - PG_CONCURRENCY_ERRORS_TO_RETRY, - PG_RETRY, -) +from odoo.addons.queue_job.controllers.main import PG_RETRY from odoo.addons.queue_job.exception import FailedJobError, RetryableJobError from odoo.addons.queue_job.job import Job @@ -72,7 +70,7 @@ def _process(self, commit=False): job.store() except OperationalError as err: # Automatically retry the typical transaction serialization errors - if err.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY: + if not isinstance(err, PG_CONCURRENCY_EXCEPTIONS_TO_RETRY): raise message = str(err.pgerror or "") job.postpone(result=message, seconds=PG_RETRY) diff --git a/queue_job_subscribe/README.rst b/queue_job_subscribe/README.rst new file mode 100644 index 0000000000..b82fbeb8c1 --- /dev/null +++ b/queue_job_subscribe/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=================== +Queue Job Subscribe +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dad459b8a0a33d0be9cba5350c77a9ae1c891c880940d16d0103f18545601ab2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/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/20.0/queue_job_subscribe + :alt: OCA/queue +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/queue-20-0/queue-20-0-queue_job_subscribe + :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=20.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows users to be member of group Job Queue Manager without +becoming follower of failed jobs. This can avoid for some users to +receive a lot of emails in case of failing jobs. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +On the user configuration form, there is new Job Notifications checkbox. + +If checked, the user becomes follower of failed jobs if he/she is part +of the Job Queue Manager group. + +If not checked, the user does not become follower of failed jobs. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Acsone SA/NV + +Contributors +------------ + +- Cédric Pigeon +- Stéphane Bidoul +- Tran Quoc Duong + +Other credits +------------- + +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/queue_job_subscribe/__init__.py b/queue_job_subscribe/__init__.py new file mode 100644 index 0000000000..6a125affcd --- /dev/null +++ b/queue_job_subscribe/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/queue_job_subscribe/__manifest__.py b/queue_job_subscribe/__manifest__.py new file mode 100644 index 0000000000..f24cf1c9ee --- /dev/null +++ b/queue_job_subscribe/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Queue Job Subscribe", + "version": "20.0.1.0.0", + "author": "Acsone SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/queue", + "summary": "Control which users are subscribed to queue job notifications", + "license": "AGPL-3", + "category": "Generic Modules", + "depends": ["queue_job"], + "data": ["views/res_users_view.xml"], + "installable": True, +} diff --git a/queue_job_subscribe/i18n/ar.po b/queue_job_subscribe/i18n/ar.po new file mode 100644 index 0000000000..cd2e4cef66 --- /dev/null +++ b/queue_job_subscribe/i18n/ar.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Arabic (https://www.transifex.com/oca/teams/23907/ar/)\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "المستخدمون" diff --git a/queue_job_subscribe/i18n/bg.po b/queue_job_subscribe/i18n/bg.po new file mode 100644 index 0000000000..92a910d0e9 --- /dev/null +++ b/queue_job_subscribe/i18n/bg.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# Kaloyan Naumov , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: Kaloyan Naumov , 2017\n" +"Language-Team: Bulgarian (https://www.transifex.com/oca/teams/23907/bg/)\n" +"Language: bg\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Конектори" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" diff --git a/queue_job_subscribe/i18n/ca.po b/queue_job_subscribe/i18n/ca.po new file mode 100644 index 0000000000..ed4753f186 --- /dev/null +++ b/queue_job_subscribe/i18n/ca.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2022-04-13 14:05+0000\n" +"Last-Translator: Noel estudillo \n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Connectors" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Si aquesta marca està marcada i l'usuari és Connector Manager, rebrà " +"notificacions de feina." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Notificacions de feina" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Tasca de Cua" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Usuaris" diff --git a/queue_job_subscribe/i18n/da.po b/queue_job_subscribe/i18n/da.po new file mode 100644 index 0000000000..47146df0b4 --- /dev/null +++ b/queue_job_subscribe/i18n/da.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Danish (https://www.transifex.com/oca/teams/23907/da/)\n" +"Language: da\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Brugere" diff --git a/queue_job_subscribe/i18n/de.po b/queue_job_subscribe/i18n/de.po new file mode 100644 index 0000000000..19160a653e --- /dev/null +++ b/queue_job_subscribe/i18n/de.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-24 00:51+0000\n" +"PO-Revision-Date: 2020-07-22 12:20+0000\n" +"Last-Translator: c2cdidier \n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Connector" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Wenn dieses Kennzeichen gesetzt ist und der Benutzer ist Verbindungsmanager, " +"dann wird er Job-Hinweise erhalten." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Job Benachrichtigungen" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Warteschlange Job" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Benutzer" + +#~ msgid "Sale Pricelist" +#~ msgstr "Verkaufspreisliste" + +#~ msgid "" +#~ "This pricelist will be used, instead of the default one, for sales to the " +#~ "current partner" +#~ msgstr "" +#~ "Diese Preisliste wird anstelle der Vorgabe bei Verkäufen an diesen " +#~ "Partner verwendet" diff --git a/queue_job_subscribe/i18n/el_GR.po b/queue_job_subscribe/i18n/el_GR.po new file mode 100644 index 0000000000..eded39a248 --- /dev/null +++ b/queue_job_subscribe/i18n/el_GR.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Greek (Greece) (https://www.transifex.com/oca/teams/23907/" +"el_GR/)\n" +"Language: el_GR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Χρήστες" diff --git a/queue_job_subscribe/i18n/es.po b/queue_job_subscribe/i18n/es.po new file mode 100644 index 0000000000..67c6e10713 --- /dev/null +++ b/queue_job_subscribe/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2023-10-15 18:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Conectores" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Si esta bandera está marcada y el usuario es Connector Manager, recibirá " +"notificaciones de trabajo." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Notificaciones de trabajos" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Trabajo de Cola" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "Usuario" + +#~ msgid "Users" +#~ msgstr "Usuarios" diff --git a/queue_job_subscribe/i18n/es_ES.po b/queue_job_subscribe/i18n/es_ES.po new file mode 100644 index 0000000000..e19cd06e84 --- /dev/null +++ b/queue_job_subscribe/i18n/es_ES.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (Spain) (https://www.transifex.com/oca/teams/23907/" +"es_ES/)\n" +"Language: es_ES\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Usuarios" diff --git a/queue_job_subscribe/i18n/fi.po b/queue_job_subscribe/i18n/fi.po new file mode 100644 index 0000000000..b5ecad2df3 --- /dev/null +++ b/queue_job_subscribe/i18n/fi.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Käyttäjät" diff --git a/queue_job_subscribe/i18n/fr.po b/queue_job_subscribe/i18n/fr.po new file mode 100644 index 0000000000..905d96668e --- /dev/null +++ b/queue_job_subscribe/i18n/fr.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2020-07-22 12:20+0000\n" +"Last-Translator: c2cdidier \n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Connecteurs" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Si cette case est cochée et que l'utilisateur est Administrateur Connecteur, " +"il recevra les notifications des jobs." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Notifications des jobs" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Queue de jobs" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Utilisateurs" diff --git a/queue_job_subscribe/i18n/fr_CH.po b/queue_job_subscribe/i18n/fr_CH.po new file mode 100644 index 0000000000..67554b4ce9 --- /dev/null +++ b/queue_job_subscribe/i18n/fr_CH.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (Switzerland) (https://www.transifex.com/oca/" +"teams/23907/fr_CH/)\n" +"Language: fr_CH\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Utilisateurs" diff --git a/queue_job_subscribe/i18n/hr.po b/queue_job_subscribe/i18n/hr.po new file mode 100644 index 0000000000..5674992c77 --- /dev/null +++ b/queue_job_subscribe/i18n/hr.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Korisnici" diff --git a/queue_job_subscribe/i18n/hr_HR.po b/queue_job_subscribe/i18n/hr_HR.po new file mode 100644 index 0000000000..f38ad04aed --- /dev/null +++ b/queue_job_subscribe/i18n/hr_HR.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/" +"hr_HR/)\n" +"Language: hr_HR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Korisnici" diff --git a/queue_job_subscribe/i18n/hu.po b/queue_job_subscribe/i18n/hu.po new file mode 100644 index 0000000000..c593c729ea --- /dev/null +++ b/queue_job_subscribe/i18n/hu.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Hungarian (https://www.transifex.com/oca/teams/23907/hu/)\n" +"Language: hu\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Csatolók" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Sorbanálló feladatok" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" diff --git a/queue_job_subscribe/i18n/it.po b/queue_job_subscribe/i18n/it.po new file mode 100644 index 0000000000..2170939927 --- /dev/null +++ b/queue_job_subscribe/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2024-02-05 00:26+0000\n" +"Last-Translator: mymage \n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Connettori" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Se questa selezione è attiva e l'utente è un responsabile connettore, " +"riceverà le notifiche di lavoro." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Notifiche lavoro" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Lavoro in coda" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "Utente" + +#~ msgid "Users" +#~ msgstr "Utenti" diff --git a/queue_job_subscribe/i18n/nl.po b/queue_job_subscribe/i18n/nl.po new file mode 100644 index 0000000000..4931468dcc --- /dev/null +++ b/queue_job_subscribe/i18n/nl.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Connectors" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Geplande taken" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Gebruikers" diff --git a/queue_job_subscribe/i18n/pt_BR.po b/queue_job_subscribe/i18n/pt_BR.po new file mode 100644 index 0000000000..b01a6d8382 --- /dev/null +++ b/queue_job_subscribe/i18n/pt_BR.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +# Rodrigo de Almeida Sottomaior Macedo , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-01 16:11+0000\n" +"PO-Revision-Date: 2024-07-06 20:58+0000\n" +"Last-Translator: Rodrigo Sottomaior Macedo " +"\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Conectores" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Se este sinalizador estiver marcado e o usuário for Connector Manager, ele " +"receberá notificações de tarefa." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "Notificações de trabalho" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Fila de tarefas" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "Usuário" + +#~ msgid "Users" +#~ msgstr "Usuários" + +#~ msgid "Sale Pricelist" +#~ msgstr "Lista de Preços de Venda" diff --git a/queue_job_subscribe/i18n/queue_job_subscribe.pot b/queue_job_subscribe/i18n/queue_job_subscribe.pot new file mode 100644 index 0000000000..0d5d7fdaeb --- /dev/null +++ b/queue_job_subscribe/i18n/queue_job_subscribe.pot @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * queue_job_subscribe +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_queue_job__display_name +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__display_name +msgid "Display Name" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_queue_job__id +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__id +msgid "ID" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" diff --git a/queue_job_subscribe/i18n/sl.po b/queue_job_subscribe/i18n/sl.po new file mode 100644 index 0000000000..65fe1eaf3a --- /dev/null +++ b/queue_job_subscribe/i18n/sl.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +# Matjaž Mozetič , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: Matjaž Mozetič , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "Povezovalniki" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" +"Če označeno, bo uporabnik, ki je upravitelj povezovalnikov prejemal " +"obvestila o delu." + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +#, fuzzy +msgid "Job Notifications" +msgstr "Obvestila o delu" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "Delo čakalne vrste" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Uporabniki" + +#~ msgid "Sale Pricelist" +#~ msgstr "Prodajni cenik" + +#~ msgid "" +#~ "This pricelist will be used, instead of the default one, for sales to the " +#~ "current partner" +#~ msgstr "" +#~ "Ta cenik bo uporabljen namesto privzetega za prodajo trenutnemu partnerju." diff --git a/queue_job_subscribe/i18n/tr.po b/queue_job_subscribe/i18n/tr.po new file mode 100644 index 0000000000..a706101b69 --- /dev/null +++ b/queue_job_subscribe/i18n/tr.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Kullanıcılar" diff --git a/queue_job_subscribe/i18n/tr_TR.po b/queue_job_subscribe/i18n/tr_TR.po new file mode 100644 index 0000000000..dc9d103a5c --- /dev/null +++ b/queue_job_subscribe/i18n/tr_TR.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2017-04-05 00:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/" +"tr_TR/)\n" +"Language: tr_TR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "" + +#~ msgid "Users" +#~ msgstr "Kullanıcılar" diff --git a/queue_job_subscribe/i18n/zh_CN.po b/queue_job_subscribe/i18n/zh_CN.po new file mode 100644 index 0000000000..cd6e587143 --- /dev/null +++ b/queue_job_subscribe/i18n/zh_CN.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * connector_job_subscribe +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-05 00:42+0000\n" +"PO-Revision-Date: 2024-07-02 09:47+0000\n" +"Last-Translator: xtanuiha \n" +"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/" +"zh_CN/)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.17\n" + +#. module: queue_job_subscribe +#: model_terms:ir.ui.view,arch_db:queue_job_subscribe.view_user_connector_form +msgid "Connectors" +msgstr "连接器" + +#. module: queue_job_subscribe +#: model:ir.model.fields,help:queue_job_subscribe.field_res_users__subscribe_job +msgid "" +"If this flag is checked and the user is Connector Manager, he will receive " +"job notifications." +msgstr "如果选中此标志并且用户是连接器管理,则他将收到作业通知。" + +#. module: queue_job_subscribe +#: model:ir.model.fields,field_description:queue_job_subscribe.field_res_users__subscribe_job +msgid "Job Notifications" +msgstr "作业通知" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_queue_job +msgid "Queue Job" +msgstr "队列中作业" + +#. module: queue_job_subscribe +#: model:ir.model,name:queue_job_subscribe.model_res_users +msgid "User" +msgstr "用户" + +#~ msgid "Users" +#~ msgstr "用户" diff --git a/queue_job_subscribe/models/__init__.py b/queue_job_subscribe/models/__init__.py new file mode 100644 index 0000000000..b5dc1e9f81 --- /dev/null +++ b/queue_job_subscribe/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import queue_job +from . import res_users diff --git a/queue_job_subscribe/models/queue_job.py b/queue_job_subscribe/models/queue_job.py new file mode 100644 index 0000000000..9b82516f2c --- /dev/null +++ b/queue_job_subscribe/models/queue_job.py @@ -0,0 +1,13 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class QueueJob(models.Model): + _inherit = "queue.job" + + def _subscribe_users_domain(self): + domain = super()._subscribe_users_domain() + domain.append(("subscribe_job", "=", True)) + return domain diff --git a/queue_job_subscribe/models/res_users.py b/queue_job_subscribe/models/res_users.py new file mode 100644 index 0000000000..8afc3d3673 --- /dev/null +++ b/queue_job_subscribe/models/res_users.py @@ -0,0 +1,17 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + subscribe_job = fields.Boolean( + "Job Notifications", + default=True, + help="If this flag is checked and the " + "user is Connector Manager, he will " + "receive job notifications.", + index=True, + ) diff --git a/queue_job_subscribe/pyproject.toml b/queue_job_subscribe/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/queue_job_subscribe/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/queue_job_subscribe/readme/CONTRIBUTORS.md b/queue_job_subscribe/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..85798bdf39 --- /dev/null +++ b/queue_job_subscribe/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Cédric Pigeon \<\> +- Stéphane Bidoul \<\> +- Tran Quoc Duong \<\> diff --git a/queue_job_subscribe/readme/CREDITS.md b/queue_job_subscribe/readme/CREDITS.md new file mode 100644 index 0000000000..83b3ec91f7 --- /dev/null +++ b/queue_job_subscribe/readme/CREDITS.md @@ -0,0 +1 @@ +The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. diff --git a/queue_job_subscribe/readme/DESCRIPTION.md b/queue_job_subscribe/readme/DESCRIPTION.md new file mode 100644 index 0000000000..534b131f5b --- /dev/null +++ b/queue_job_subscribe/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows users to be member of group Job Queue Manager without becoming follower of failed jobs. +This can avoid for some users to receive a lot of emails in case of failing jobs. diff --git a/queue_job_subscribe/readme/USAGE.md b/queue_job_subscribe/readme/USAGE.md new file mode 100644 index 0000000000..ff15032678 --- /dev/null +++ b/queue_job_subscribe/readme/USAGE.md @@ -0,0 +1,5 @@ +On the user configuration form, there is new Job Notifications checkbox. + +If checked, the user becomes follower of failed jobs if he/she is part of the Job Queue Manager group. + +If not checked, the user does not become follower of failed jobs. diff --git a/queue_job_subscribe/static/description/icon.png b/queue_job_subscribe/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/queue_job_subscribe/static/description/icon.png differ diff --git a/queue_job_subscribe/static/description/index.html b/queue_job_subscribe/static/description/index.html new file mode 100644 index 0000000000..615e26a684 --- /dev/null +++ b/queue_job_subscribe/static/description/index.html @@ -0,0 +1,447 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Queue Job Subscribe

+ +

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runboat

+

This module allows users to be member of group Job Queue Manager without +becoming follower of failed jobs. This can avoid for some users to +receive a lot of emails in case of failing jobs.

+

Table of contents

+ +
+

Usage

+

On the user configuration form, there is new Job Notifications checkbox.

+

If checked, the user becomes follower of failed jobs if he/she is part +of the Job Queue Manager group.

+

If not checked, the user does not become follower of failed jobs.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Acsone SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/queue_job_subscribe/tests/__init__.py b/queue_job_subscribe/tests/__init__.py new file mode 100644 index 0000000000..292a860ce5 --- /dev/null +++ b/queue_job_subscribe/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_job_subscribe diff --git a/queue_job_subscribe/tests/test_job_subscribe.py b/queue_job_subscribe/tests/test_job_subscribe.py new file mode 100644 index 0000000000..5cdb6d51ab --- /dev/null +++ b/queue_job_subscribe/tests/test_job_subscribe.py @@ -0,0 +1,97 @@ +# Copyright 2016 Cédric Pigeon +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import Command +from odoo.tests import common + +from odoo.addons.queue_job.job import Job + + +class TestJobSubscribe(common.TransactionCase): + def setUp(self): + super().setUp() + self.env = self.env(context=dict(self.env.context, tracking_disable=True)) + grp_queue_job_manager = self.ref("queue_job.group_queue_job_manager") + self.other_partner_a = self.env["res.partner"].create( + {"name": "My Company a", "is_company": True, "email": "test@tes.ttest"} + ) + self.other_user_a = ( + self.env["res.users"] + .with_context(no_reset_password=True) + .create( + { + "partner_id": self.other_partner_a.id, + "login": "my_login a", + "name": "my user", + "group_ids": [Command.link(grp_queue_job_manager)], + } + ) + ) + self.other_partner_b = self.env["res.partner"].create( + {"name": "My Company b", "is_company": True, "email": "test@tes.ttest"} + ) + self.other_user_b = self.env["res.users"].create( + { + "partner_id": self.other_partner_b.id, + "login": "my_login_b", + "name": "my user 1", + "group_ids": [Command.link(grp_queue_job_manager)], + } + ) + + def _create_failed_job(self): + method = self.env["res.users"].with_user(self.other_user_a).mapped + test_job = Job(method) + test_job.store() + test_job_record = self.env["queue.job"].search([("uuid", "=", test_job.uuid)]) + test_job_record.write({"state": "failed"}) + return test_job_record + + def test_job_subscription_all_follow(self): + """ + When a job is created, all user of group + queue_job.group_queue_job_manager are automatically set as + follower + """ + + ################################# + # Test 1: All users are followers + ################################# + stored = self._create_failed_job() + users = self.env["res.users"].search( + [("group_ids", "=", self.ref("queue_job.group_queue_job_manager"))] + ) + self.assertEqual(len(stored.message_follower_ids), len(users)) + expected_partners = [u.partner_id for u in users] + self.assertSetEqual( + set(stored.mapped("message_follower_ids.partner_id")), + set(expected_partners), + ) + followers_id = [f.id for f in stored.mapped("message_follower_ids.partner_id")] + self.assertIn(self.other_partner_a.id, followers_id) + self.assertIn(self.other_partner_b.id, followers_id) + + def test_job_subscription_not_follow(self): + """ + If the flag subscribe_job is not set as follower + """ + ########################################### + # Test 2: User b request to not be follower + ########################################### + self.other_user_b.write({"subscribe_job": False}) + stored = self._create_failed_job() + users = self.env["res.users"].search( + [ + ("group_ids", "=", self.ref("queue_job.group_queue_job_manager")), + ("subscribe_job", "=", True), + ] + ) + self.assertEqual(len(stored.message_follower_ids), len(users)) + expected_partners = [u.partner_id for u in users] + self.assertSetEqual( + set(stored.mapped("message_follower_ids.partner_id")), + set(expected_partners), + ) + followers_id = [f.id for f in stored.mapped("message_follower_ids.partner_id")] + self.assertIn(self.other_partner_a.id, followers_id) + self.assertNotIn(self.other_partner_b.id, followers_id) diff --git a/queue_job_subscribe/views/res_users_view.xml b/queue_job_subscribe/views/res_users_view.xml new file mode 100644 index 0000000000..228cbd3499 --- /dev/null +++ b/queue_job_subscribe/views/res_users_view.xml @@ -0,0 +1,17 @@ + + + + res.user.connector.form + res.users + + + + + + + + + + + + diff --git a/requirements.txt b/requirements.txt index b4d39fb9e0..12783be9a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ # generated from manifests external_dependencies +openupgradelib requests diff --git a/test_queue_job/README.rst b/test_queue_job/README.rst new file mode 100644 index 0000000000..de9b8cd285 --- /dev/null +++ b/test_queue_job/README.rst @@ -0,0 +1,70 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +============== +Test Job Queue +============== + +This addon is not meant to be used. It extends the Odoo Models +in order to run automated tests on the jobs queue. + +The basic tests are integrated with the ``queue_job`` addon, +but for the tests that need several job methods are done in +this module to avoid to pollute the Models. + +Installation +============ + +Nothing particular. + +Usage +===== + +This module only contains Python tests. + +Known issues / Roadmap +====================== + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Guewen Baconnier +* Stéphane Bidoul +* Matthieu Dietrich +* Jos De Graeve +* David Lefever +* Laurent Mignon +* Laetitia Gangloff + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. + diff --git a/test_queue_job/__init__.py b/test_queue_job/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/test_queue_job/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/test_queue_job/__manifest__.py b/test_queue_job/__manifest__.py new file mode 100644 index 0000000000..8b6684fdb5 --- /dev/null +++ b/test_queue_job/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +{ + "name": "Queue Job Tests", + "version": "20.0.2.2.0", + "author": "Camptocamp,Odoo Community Association (OCA)", + "license": "LGPL-3", + "category": "Generic Modules", + "depends": ["queue_job"], + "website": "https://github.com/OCA/queue", + "data": [ + "data/queue_job_channel_data.xml", + "data/queue_job_function_data.xml", + "security/ir.access.csv", + "data/queue_job_test_job.xml", + ], + "maintainers": ["sbidoul"], + "installable": True, +} diff --git a/test_queue_job/data/queue_job_channel_data.xml b/test_queue_job/data/queue_job_channel_data.xml new file mode 100644 index 0000000000..3240e1e5ba --- /dev/null +++ b/test_queue_job/data/queue_job_channel_data.xml @@ -0,0 +1,11 @@ + + + + sub + + + + subsub + + + diff --git a/test_queue_job/data/queue_job_function_data.xml b/test_queue_job/data/queue_job_function_data.xml new file mode 100644 index 0000000000..5ae67f3f33 --- /dev/null +++ b/test_queue_job/data/queue_job_function_data.xml @@ -0,0 +1,74 @@ + + + + + testing_method + + + + + job_with_retry_pattern + + + + + job_with_retry_pattern__no_zero + + + + + job_commit_with_arg_records + + + + + job_sub_channel + + + + + job_a + + + + testing_related_action__return_none + + + + + testing_related_action__kwargs + + + + + testing_related_action__store + + + diff --git a/test_queue_job/data/queue_job_test_job.xml b/test_queue_job/data/queue_job_test_job.xml new file mode 100644 index 0000000000..8e9ccc9da3 --- /dev/null +++ b/test_queue_job/data/queue_job_test_job.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/test_queue_job/i18n/de.po b/test_queue_job/i18n/de.po new file mode 100644 index 0000000000..59b37f4e22 --- /dev/null +++ b/test_queue_job/i18n/de.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-11-04 14:44+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "Erstellt von" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "Erstellt am" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "Anzeigename" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "ID" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "Zuletzt aktualisiert von" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "Zuletzt aktualisiert am" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "Bezeichnung" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "Job einreihen" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "" + +#~ msgid "Last Modified on" +#~ msgstr "Zuletzt geändert am" diff --git a/test_queue_job/i18n/es.po b/test_queue_job/i18n/es.po new file mode 100644 index 0000000000..d17e20c96d --- /dev/null +++ b/test_queue_job/i18n/es.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-15 18:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "Información Adicional" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "ID(identificación)" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "Actualizado por Última vez por" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "Última Actualización el" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "Nombre" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "Cola de Trabajo" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "Modelo de prueba para queue.channel" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "Modelo de prueba para queue.job" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "Modelo de prueba para acciones relacionadas" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" diff --git a/test_queue_job/i18n/fa.po b/test_queue_job/i18n/fa.po new file mode 100644 index 0000000000..e1beba12d0 --- /dev/null +++ b/test_queue_job/i18n/fa.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: fa\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "" diff --git a/test_queue_job/i18n/it.po b/test_queue_job/i18n/it.po new file mode 100644 index 0000000000..7dbcf88d67 --- /dev/null +++ b/test_queue_job/i18n/it.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-12 11:39+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "Informazioni aggiuntive" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "ID" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "Nome" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "Lavoro in coda" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "Prova modello per queue.channel" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "Prova modello per queue.job" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "Prova modello per azioni collegate" diff --git a/test_queue_job/i18n/test_queue_job.pot b/test_queue_job/i18n/test_queue_job.pot new file mode 100644 index 0000000000..8599ffbca3 --- /dev/null +++ b/test_queue_job/i18n/test_queue_job.pot @@ -0,0 +1,88 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 19.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "" diff --git a/test_queue_job/i18n/zh_CN.po b/test_queue_job/i18n/zh_CN.po new file mode 100644 index 0000000000..7eb2a4bb43 --- /dev/null +++ b/test_queue_job/i18n/zh_CN.po @@ -0,0 +1,92 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * test_queue_job +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-02 09:47+0000\n" +"Last-Translator: xtanuiha \n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.17\n" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_queue_job__additional_info +msgid "Additional Info" +msgstr "附加信息" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_uid +msgid "Created by" +msgstr "创建者" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__create_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__create_date +msgid "Created on" +msgstr "创建时间" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__display_name +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__display_name +msgid "Display Name" +msgstr "显示名称" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__id +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__id +msgid "ID" +msgstr "ID" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_uid +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_uid +msgid "Last Updated by" +msgstr "最后更新者" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_channel__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__write_date +#: model:ir.model.fields,field_description:test_queue_job.field_test_related_action__write_date +msgid "Last Updated on" +msgstr "最后更新时间" + +#. module: test_queue_job +#: model:ir.model.fields,field_description:test_queue_job.field_test_queue_job__name +msgid "Name" +msgstr "名称" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_queue_job +msgid "Queue Job" +msgstr "队列作业" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_channel +msgid "Test model for queue.channel" +msgstr "测试模型 queue.channel" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_queue_job +msgid "Test model for queue.job" +msgstr "测试模型queue.job" + +#. module: test_queue_job +#: model:ir.model,name:test_queue_job.model_test_related_action +msgid "Test model for related actions" +msgstr "测试模型的相关动作" + +#~ msgid "Last Modified on" +#~ msgstr "最后修改时间" diff --git a/test_queue_job/models/__init__.py b/test_queue_job/models/__init__.py new file mode 100644 index 0000000000..483288c9af --- /dev/null +++ b/test_queue_job/models/__init__.py @@ -0,0 +1 @@ +from . import test_models diff --git a/test_queue_job/models/test_models.py b/test_queue_job/models/test_models.py new file mode 100644 index 0000000000..2d6c2cd385 --- /dev/null +++ b/test_queue_job/models/test_models.py @@ -0,0 +1,221 @@ +# Copyright 2016 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +import functools +from datetime import datetime, timedelta + +from odoo import api, fields, models + +from odoo.addons.queue_job.delay import chain +from odoo.addons.queue_job.exception import RetryableJobError +from odoo.addons.queue_job.job import identity_exact + + +class QueueJob(models.Model): + _inherit = "queue.job" + + additional_info = fields.Char() + + def testing_related_method(self, **kwargs): + return self, kwargs + + def testing_related__none(self, **kwargs): + return None + + def testing_related__url(self, **kwargs): + assert "url" in kwargs, "url required" + subject = self.args[0] + return { + "type": "ir.actions.act_url", + "target": "new", + "url": kwargs["url"].format(subject=subject), + } + + @api.model + def _create_test_started_job(self, uuid): + """Create started jobs to be used within tests""" + self.env["queue.job"].with_context( + _job_edit_sentinel=self.env["queue.job"].EDIT_SENTINEL, + ).create( + { + "uuid": uuid, + "state": "started", + "model_name": "queue.job", + "method_name": "write", + } + ) + + @api.model + def _create_test_enqueued_job(self, uuid): + """Create enqueued jobs to be used within tests""" + self.env["queue.job"].with_context( + _job_edit_sentinel=self.env["queue.job"].EDIT_SENTINEL, + ).create( + { + "uuid": uuid, + "state": "enqueued", + "model_name": "queue.job", + "method_name": "write", + "date_enqueued": datetime.now() - timedelta(minutes=1), # noqa: DTZ005 + } + ) + + +class ModelTestQueueJob(models.Model): + _name = "test.queue.job" + _description = "Test model for queue.job" + + name = fields.Char() + + # to test the context is serialized/deserialized properly + @api.model + def _job_prepare_context_before_enqueue_keys(self): + return ("tz", "lang", "allowed_company_ids") + + def testing_method(self, *args, **kwargs): + """Method used for tests + + Return always the arguments and keyword arguments received + """ + if kwargs.get("raise_retry"): + raise RetryableJobError("Must be retried later") + if kwargs.get("return_context"): + return self.env.context + return args, kwargs + + def create_ir_logging(self, message, level="info"): + return self.env["ir.logging"].create( + { + "name": "test_queue_job", + "type": "server", + "dbname": self.env.cr.dbname, + "message": message, + "path": "job", + "func": "create_ir_logging", + "line": 1, + } + ) + + def no_description(self): + return + + def job_with_retry_pattern(self): + return + + def job_with_retry_pattern__no_zero(self): + return + + def mapped(self, func): + return super().mapped(func) + + def job_alter_mutable(self, mutable_arg, mutable_kwarg=None): + mutable_arg.append(2) + mutable_kwarg["b"] = 2 + return mutable_arg, mutable_kwarg + + def job_commit_with_arg_records( + self, record, record_list=None, record_dict=None, token=None + ): + assert record.env.cr is self.env.cr, "record argument cursor was not rebound" + assert not record_list or record_list[0].env.cr is self.env.cr, ( + "record list argument cursor was not rebound" + ) + assert not record_dict or record_dict["record"].env.cr is self.env.cr, ( + "record dict argument cursor was not rebound" + ) + record.env.cr.commit() # pylint: disable=invalid-commit + return token + + def delay_me(self, arg, kwarg=None): + return arg, kwarg + + def delay_me_options_job_options(self): + return { + "identity_key": "my_job_identity", + } + + def delay_me_options(self): + return "ok" + + def delay_me_context_key(self): + return "ok" + + def _register_hook(self): + patched = self._patch_job_auto_delay("delay_me") + type(self).delay_me = functools.update_wrapper(patched, type(self).delay_me) + + patched = self._patch_job_auto_delay("delay_me_options") + type(self).delay_me_options = functools.update_wrapper( + patched, type(self).delay_me_options + ) + + patched = self._patch_job_auto_delay( + "delay_me_context_key", + context_key="auto_delay_delay_me_context_key", + ) + type(self).delay_me_context_key = functools.update_wrapper( + patched, type(self).delay_me_context_key + ) + return super()._register_hook() + + def _job_store_values(self, job): + value = "JUST_TESTING" + if job.state == "failed": + value += "_BUT_FAILED" + return {"additional_info": value} + + def button_that_uses_with_delay(self): + self.with_delay( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ).testing_method(1, foo=2) + + def button_that_uses_delayable_chain(self): + delayables = chain( + self.delayable( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ).testing_method(1, foo=2), + self.delayable().testing_method("x", foo="y"), + self.delayable().no_description(), + ) + delayables.delay() + + +class ModelTestQueueChannel(models.Model): + _name = "test.queue.channel" + _description = "Test model for queue.channel" + + def job_a(self): + return + + def job_b(self): + return + + def job_sub_channel(self): + return + + +class ModelTestRelatedAction(models.Model): + _name = "test.related.action" + _description = "Test model for related actions" + + def testing_related_action__no(self): + return + + def testing_related_action__return_none(self): + return + + def testing_related_action__kwargs(self): + return + + def testing_related_action__store(self): + return diff --git a/test_queue_job/pyproject.toml b/test_queue_job/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/test_queue_job/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/test_queue_job/security/ir.access.csv b/test_queue_job/security/ir.access.csv new file mode 100644 index 0000000000..271adba2c9 --- /dev/null +++ b/test_queue_job/security/ir.access.csv @@ -0,0 +1,4 @@ +id,name,model_id,group_id/id,operation,domain +access_test_queue_job,access_test_queue_job,test.queue.job,queue_job.group_queue_job_manager,crud, +access_test_queue_channel,access_test_queue_channel,test.queue.channel,queue_job.group_queue_job_manager,crud, +access_test_related_action,access_test_related_action,test.related.action,queue_job.group_queue_job_manager,crud, diff --git a/test_queue_job/static/description/icon.png b/test_queue_job/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/test_queue_job/static/description/icon.png differ diff --git a/test_queue_job/tests/__init__.py b/test_queue_job/tests/__init__.py new file mode 100644 index 0000000000..0cfacebdf3 --- /dev/null +++ b/test_queue_job/tests/__init__.py @@ -0,0 +1,11 @@ +from . import test_acquire_job +from . import test_autovacuum +from . import test_delayable +from . import test_dependencies +from . import test_job +from . import test_job_auto_delay +from . import test_job_channels +from . import test_job_function +from . import test_related_actions +from . import test_delay_mocks +from . import test_requeue_dead_job diff --git a/test_queue_job/tests/common.py b/test_queue_job/tests/common.py new file mode 100644 index 0000000000..d3173a2198 --- /dev/null +++ b/test_queue_job/tests/common.py @@ -0,0 +1,32 @@ +# Copyright 2016-2019 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo.tests import common + +from odoo.addons.queue_job.job import Job + + +class JobCommonCase(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.queue_job = cls.env["queue.job"] + cls.user = cls.env["res.users"] + cls.method = cls.env["test.queue.job"].testing_method + + def _create_job(self): + test_job = Job(self.method) + test_job.store() + stored = Job.db_records_from_uuids(self.env, [test_job.uuid]) + self.assertEqual(len(stored), 1) + return stored + + def _get_demo_job(self, uuid): + # job created during load of demo data + job = self.env["queue.job"].search([("uuid", "=", uuid)], limit=1) + self.assertTrue( + job, + f"Demo data queue job {uuid!r} should be loaded in order " + "to make this test work", + ) + return job diff --git a/test_queue_job/tests/test_acquire_job.py b/test_queue_job/tests/test_acquire_job.py new file mode 100644 index 0000000000..3f0c92a2be --- /dev/null +++ b/test_queue_job/tests/test_acquire_job.py @@ -0,0 +1,51 @@ +# Copyright 2026 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging +from unittest import mock + +from odoo.tests import tagged + +from odoo.addons.queue_job.controllers.main import RunJobController + +from .common import JobCommonCase + + +@tagged("post_install", "-at_install") +class TestRequeueDeadJob(JobCommonCase): + def test_acquire_enqueued_job(self): + job_record = self._get_demo_job(uuid="test_enqueued_job") + self.assertFalse( + self.env["queue.job.lock"].search( + [("queue_job_id", "=", job_record.id)], + ), + "A job lock record should not exist at this point", + ) + with mock.patch.object( + self.env.cr, "commit", mock.Mock(side_effect=self.env.flush_all) + ) as mock_commit: + job = RunJobController._acquire_job(self.env, job_uuid="test_enqueued_job") + mock_commit.assert_called_once() + self.assertIsNotNone(job) + self.assertEqual(job.uuid, "test_enqueued_job") + self.assertEqual(job.state, "started") + self.assertTrue( + self.env["queue.job.lock"].search( + [("queue_job_id", "=", job_record.id)] + ), + "A job lock record should exist at this point", + ) + + def test_acquire_started_job(self): + with ( + mock.patch.object( + self.env.cr, "commit", mock.Mock(side_effect=self.env.flush_all) + ) as mock_commit, + self.assertLogs(level=logging.WARNING) as logs, + ): + job = RunJobController._acquire_job(self.env, "test_started_job") + mock_commit.assert_not_called() + self.assertIsNone(job) + self.assertIn( + "was requested to run job test_started_job, but it does not exist", + logs.output[0], + ) diff --git a/test_queue_job/tests/test_autovacuum.py b/test_queue_job/tests/test_autovacuum.py new file mode 100644 index 0000000000..dc8e45125c --- /dev/null +++ b/test_queue_job/tests/test_autovacuum.py @@ -0,0 +1,105 @@ +# Copyright 2019 Versada UAB +# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). +# ruff: noqa: DTZ005 + +from datetime import datetime, timedelta + +from .common import JobCommonCase + + +class TestQueueJobAutovacuum(JobCommonCase): + def test_old_jobs_are_deleted_by_autovacuum(self): + """Old jobs are deleted by the autovacuum.""" + date_done = datetime.now() - timedelta( + days=self.queue_job._removal_interval + 1 + ) + stored = self._create_job() + stored.write({"date_done": date_done}) + self.assertEqual(self.env["queue.job"]._gc_old_jobs(), (1, False)) + self.assertFalse(stored.exists()) + + def test_old_cancelled_jobs_are_deleted_by_autovacuum(self): + """Old cancelled jobs are deleted by the autovacuum.""" + date_cancelled = datetime.now() - timedelta( + days=self.queue_job._removal_interval + 1 + ) + stored = self._create_job() + stored.write({"state": "cancelled", "date_cancelled": date_cancelled}) + self.env["queue.job"]._gc_old_jobs() + self.assertFalse(stored.exists()) + + def test_autovacuum(self): + # test default removal interval + stored = self._create_job() + date_done = datetime.now() - timedelta(days=29) + stored.write({"date_done": date_done}) + self.env["queue.job"]._gc_old_jobs() + self.assertEqual( + len(self.env["queue.job"].search([("channel", "!=", False)])), 1 + ) + + date_done = datetime.now() - timedelta(days=31) + stored.write({"date_done": date_done}) + self.env["queue.job"]._gc_old_jobs() + self.assertEqual( + len(self.env["queue.job"].search([("channel", "!=", False)])), 0 + ) + + def test_autovacuum_multi_channel(self): + root_channel = self.env.ref("queue_job.channel_root") + channel_60days = self.env["queue.job.channel"].create( + {"name": "60days", "removal_interval": 60, "parent_id": root_channel.id} + ) + date_done = datetime.now() - timedelta(days=31) + job_root = self._create_job() + job_root.write({"date_done": date_done}) + job_60days = self._create_job() + job_60days.write( + {"channel": channel_60days.complete_name, "date_done": date_done} + ) + self.assertEqual( + len(self.env["queue.job"].search([("channel", "!=", False)])), 2 + ) + self.env["queue.job"]._gc_old_jobs() + self.assertEqual( + len(self.env["queue.job"].search([("channel", "!=", False)])), 1 + ) + + date_done = datetime.now() - timedelta(days=61) + job_60days.write({"date_done": date_done}) + self.env["queue.job"]._gc_old_jobs() + self.assertEqual( + len(self.env["queue.job"].search([("channel", "!=", False)])), 0 + ) + + def test_autovacuum_unknown_channel(self): + """Old jobs of an unknown channel use the root channel's interval. + + Scenario: + 1. A job ran on a channel that no longer exists. + 2. It is done for one day longer than the root channel's interval. + Expected: + - The autovacuum deletes the job. + """ + root_channel = self.env.ref("queue_job.channel_root") + stored = self._create_job() + stored.write( + { + "channel": "root.unknown", + "date_done": datetime.now() + - timedelta(days=root_channel.removal_interval + 1), + } + ) + self.env["queue.job"]._gc_old_jobs() + self.assertFalse(stored.exists()) + + def test_old_jobs_are_deleted_by_base_autovacuum_cron(self): + """Old jobs are deleted by the base autovacuum cron.""" + date_done = datetime.now() - timedelta( + days=self.queue_job._removal_interval + 1 + ) + stored = self._create_job() + stored.write({"date_done": date_done}) + with self.enter_registry_test_mode(): + self.env.ref("base.autovacuum_job").method_direct_trigger() + self.assertFalse(stored.exists()) diff --git a/test_queue_job/tests/test_delay_mocks.py b/test_queue_job/tests/test_delay_mocks.py new file mode 100644 index 0000000000..ceeb71f156 --- /dev/null +++ b/test_queue_job/tests/test_delay_mocks.py @@ -0,0 +1,398 @@ +# Copyright 2021 Guewen Baconnier +# license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html) +# ruff: noqa: C408 + +import os +from unittest import mock + +from odoo.tests import common +from odoo.tools import mute_logger + +from odoo.addons.queue_job.delay import Delayable +from odoo.addons.queue_job.job import identity_exact +from odoo.addons.queue_job.tests.common import mock_with_delay, trap_jobs + + +class TestDelayMocks(common.TransactionCase): + def test_trap_jobs_on_with_delay_model(self): + with trap_jobs() as trap: + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + trap.assert_jobs_count(1, only=self.env["test.queue.job"].testing_method) + + trap.assert_enqueued_job( + self.env["test.queue.job"].testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + + def test_trap_jobs_on_with_delay_recordset(self): + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + recordset.button_that_uses_with_delay() + trap.assert_jobs_count(1) + trap.assert_jobs_count(1, only=recordset.testing_method) + + trap.assert_enqueued_job( + recordset.testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + + def test_trap_jobs_on_with_delay_recordset_no_properties(self): + """Verify that trap_jobs() can omit properties""" + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + recordset.button_that_uses_with_delay() + + trap.assert_enqueued_job( + recordset.testing_method, + args=(1,), + kwargs={"foo": 2}, + ) + + def test_trap_jobs_on_with_delay_recordset_partial_properties(self): + """Verify that trap_jobs() can check partially properties""" + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + recordset.button_that_uses_with_delay() + + trap.assert_enqueued_job( + recordset.testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + description="Test", + eta=15, + ), + ) + + def test_trap_with_identity_key(self): + with trap_jobs() as trap: + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + trap.assert_jobs_count(1, only=self.env["test.queue.job"].testing_method) + + trap.assert_enqueued_job( + self.env["test.queue.job"].testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + + # Should not enqueue again + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + + trap.perform_enqueued_jobs() + # Should no longer be enqueued + trap.assert_jobs_count(0) + + # Can now requeue + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + + def test_trap_jobs_on_with_delay_assert_model_count_mismatch(self): + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + with self.assertRaises(AssertionError, msg="0 != 1"): + trap.assert_jobs_count(1, only=recordset.testing_method) + + def test_trap_jobs_on_with_delay_assert_recordset_count_mismatch(self): + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + recordset.button_that_uses_with_delay() + trap.assert_jobs_count(1) + with self.assertRaises(AssertionError, msg="0 != 1"): + trap.assert_jobs_count( + 1, only=self.env["test.queue.job"].testing_method + ) + + def test_trap_jobs_on_with_delay_assert_model_enqueued_mismatch(self): + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + recordset.button_that_uses_with_delay() + trap.assert_jobs_count(1) + message = ( + r"Job \.testing_method\(1, foo=2\) with " + r"properties \(channel=root\.test, description=Test, eta=15, " + "identity_key=, " + "max_retries=1, priority=15\\) was not enqueued\\.\n" + "Actual enqueued jobs:\n" + rf" \* .testing_method" + r"\(1, foo=2\) with " + r"properties \(priority=15, max_retries=1, eta=15, description=Test, " + r"channel=root.test, " + r"identity_key=\)" + ) + with self.assertRaisesRegex(AssertionError, message): + trap.assert_enqueued_job( + self.env["test.queue.job"].testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + + def test_trap_jobs_on_with_delay_assert_recordset_enqueued_mismatch(self): + recordset = self.env["test.queue.job"].create({"name": "test"}) + with trap_jobs() as trap: + self.env["test.queue.job"].button_that_uses_with_delay() + trap.assert_jobs_count(1) + message = ( + rf"Job \.testing_method\(1, foo=2\)" + r" with properties \(channel=root\.test, description=Test, eta=15, " + "identity_key=, " + "max_retries=1, priority=15\\) was not enqueued\\.\n" + "Actual enqueued jobs:\n" + r" \* .testing_method\(1, foo=2\) with properties " + r"\(priority=15, max_retries=1, eta=15, description=Test, channel=root." + r"test, identity_key=\)" + ) + with self.assertRaisesRegex(AssertionError, message): + trap.assert_enqueued_job( + recordset.testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + + def test_trap_jobs_on_graph(self): + with trap_jobs() as trap: + self.env["test.queue.job"].button_that_uses_delayable_chain() + trap.assert_jobs_count(3) + trap.assert_jobs_count(2, only=self.env["test.queue.job"].testing_method) + trap.assert_jobs_count(1, only=self.env["test.queue.job"].no_description) + + trap.assert_enqueued_job( + self.env["test.queue.job"].testing_method, + args=(1,), + kwargs={"foo": 2}, + properties=dict( + channel="root.test", + description="Test", + eta=15, + identity_key=identity_exact, + max_retries=1, + priority=15, + ), + ) + trap.assert_enqueued_job( + self.env["test.queue.job"].testing_method, + args=("x",), + kwargs={"foo": "y"}, + ) + trap.assert_enqueued_job( + self.env["test.queue.job"].no_description, + ) + + trap.perform_enqueued_jobs() + + def test_trap_jobs_perform(self): + with trap_jobs() as trap: + model = self.env["test.queue.job"] + model.with_delay(priority=1).create_ir_logging( + "test_trap_jobs_perform single" + ) + node = Delayable(model).create_ir_logging("test_trap_jobs_perform graph 1") + node2 = Delayable(model).create_ir_logging("test_trap_jobs_perform graph 2") + node3 = Delayable(model).create_ir_logging("test_trap_jobs_perform graph 3") + node2.on_done(node3) + node3.on_done(node) + node2.delay() + + # jobs are not executed + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 0) + + trap.assert_jobs_count(4) + + # perform the jobs + trap.perform_enqueued_jobs() + + trap.assert_jobs_count(0) + + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 4) + + # check if they are executed in order + self.assertEqual(logs[0].message, "test_trap_jobs_perform single") + self.assertEqual(logs[1].message, "test_trap_jobs_perform graph 2") + self.assertEqual(logs[2].message, "test_trap_jobs_perform graph 3") + self.assertEqual(logs[3].message, "test_trap_jobs_perform graph 1") + + def test_trap_jobs_prepare_context(self): + """Context is transferred to the job according to an allow-list. + + Default allow-list is: + ("tz", "lang", "allowed_company_ids", "force_company", "active_test") + It can be customized in ``Base._job_prepare_context_before_enqueue_keys``. + """ + # pylint: disable=context-overridden + with trap_jobs() as trap: + model1 = self.env["test.queue.job"].with_context({"config_key": 42}) + model2 = self.env["test.queue.job"].with_context( + {"config_key": 42, "lang": "it_IT"} + ) + model1.with_delay().testing_method("0", "K", return_context=1) + model2.with_delay().testing_method("0", "K", return_context=1) + + [job1, job2] = trap.enqueued_jobs + trap.perform_enqueued_jobs() + + self.assertEqual(job1.result, {"job_uuid": mock.ANY}) + self.assertEqual(job2.result, {"job_uuid": mock.ANY, "lang": "it_IT"}) + + def test_mock_with_delay(self): + with mock_with_delay() as (delayable_cls, delayable): + self.env["test.queue.job"].button_that_uses_with_delay() + + self.assertEqual(delayable_cls.call_count, 1) + # arguments passed in 'with_delay()' + delay_args, delay_kwargs = delayable_cls.call_args + self.assertEqual(delay_args, (self.env["test.queue.job"],)) + self.assertDictEqual( + delay_kwargs, + { + "channel": "root.test", + "description": "Test", + "eta": 15, + "identity_key": identity_exact, + "max_retries": 1, + "priority": 15, + }, + ) + + # check what's passed to the job method 'testing_method' + self.assertEqual(delayable.testing_method.call_count, 1) + delay_args, delay_kwargs = delayable.testing_method.call_args + self.assertEqual(delay_args, (1,)) + self.assertDictEqual(delay_kwargs, {"foo": 2}) + + @mute_logger("odoo.addons.queue_job.utils") + @mock.patch.dict(os.environ, {"QUEUE_JOB__NO_DELAY": "1"}) + def test_delay_graph_direct_exec_env_var(self): + node = Delayable(self.env["test.queue.job"]).create_ir_logging( + "test_delay_graph_direct_exec 1" + ) + node2 = Delayable(self.env["test.queue.job"]).create_ir_logging( + "test_delay_graph_direct_exec 2" + ) + node2.on_done(node) + node2.delay() + # jobs are executed directly + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 2) + # check if they are executed in order + self.assertEqual(logs[0].message, "test_delay_graph_direct_exec 2") + self.assertEqual(logs[1].message, "test_delay_graph_direct_exec 1") + + @mute_logger("odoo.addons.queue_job.utils") + def test_delay_graph_direct_exec_context_key(self): + node = Delayable( + self.env["test.queue.job"].with_context(queue_job__no_delay=True) + ).create_ir_logging("test_delay_graph_direct_exec 1") + node2 = Delayable(self.env["test.queue.job"]).create_ir_logging( + "test_delay_graph_direct_exec 2" + ) + node2.on_done(node) + node2.delay() + # jobs are executed directly + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 2) + # check if they are executed in order + self.assertEqual(logs[0].message, "test_delay_graph_direct_exec 2") + self.assertEqual(logs[1].message, "test_delay_graph_direct_exec 1") + + @mute_logger("odoo.addons.queue_job.utils") + @mock.patch.dict(os.environ, {"QUEUE_JOB__NO_DELAY": "1"}) + def test_delay_with_delay_direct_exec_env_var(self): + model = self.env["test.queue.job"] + model.with_delay().create_ir_logging("test_delay_graph_direct_exec 1") + # jobs are executed directly + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 1) + self.assertEqual(logs[0].message, "test_delay_graph_direct_exec 1") + + @mute_logger("odoo.addons.queue_job.utils") + def test_delay_with_delay_direct_exec_context_key(self): + model = self.env["test.queue.job"].with_context(queue_job__no_delay=True) + model.with_delay().create_ir_logging("test_delay_graph_direct_exec 1") + # jobs are executed directly + logs = self.env["ir.logging"].search( + [ + ("name", "=", "test_queue_job"), + ("func", "=", "create_ir_logging"), + ], + order="id asc", + ) + self.assertEqual(len(logs), 1) + self.assertEqual(logs[0].message, "test_delay_graph_direct_exec 1") diff --git a/test_queue_job/tests/test_delayable.py b/test_queue_job/tests/test_delayable.py new file mode 100644 index 0000000000..1d3d4b1e27 --- /dev/null +++ b/test_queue_job/tests/test_delayable.py @@ -0,0 +1,310 @@ +# copyright 2019 Camptocamp +# Copyright 2019 Guewen Baconnier +# license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +import gc +import logging + +from odoo.tests import common + +from odoo.addons.queue_job.delay import ( + Delayable, + DelayableChain, + DelayableGroup, + chain, + group, +) + + +class TestDelayable(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.queue_job = cls.env["queue.job"] + cls.test_model = cls.env["test.queue.job"] + cls.method = cls.env["test.queue.job"].testing_method + + def job_node(self, id_): + return Delayable(self.test_model).testing_method(id_) + + def assert_generated_job(self, *nodes): + for node in nodes: + self.assertTrue(node._generated_job) + job = node._generated_job + self.assertTrue(job.db_record().id) + + def assert_depends_on(self, delayable, parent_delayables): + self.assertEqual( + delayable._generated_job._depends_on, + {parent._generated_job for parent in parent_delayables}, + ) + + def assert_reverse_depends_on(self, delayable, child_delayables): + self.assertEqual( + set(delayable._generated_job._reverse_depends_on), + {child._generated_job for child in child_delayables}, + ) + + def assert_dependencies(self, nodes): + reverse_dependencies = {} + for child, parents in nodes.items(): + self.assert_depends_on(child, parents) + for parent in parents: + reverse_dependencies.setdefault(parent, set()).add(child) + for parent, children in reverse_dependencies.items(): + self.assert_reverse_depends_on(parent, children) + + def test_delayable_delay_single(self): + node = self.job_node(1) + node.delay() + self.assert_generated_job(node) + + def test_delayable_delay_on_done(self): + node = self.job_node(1) + node2 = self.job_node(2) + node.on_done(node2).delay() + self.assert_generated_job(node, node2) + self.assert_dependencies({node: {}, node2: {node}}) + + def test_delayable_delay_done_multi(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node.on_done(node2, node3).delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies({node: {}, node2: {node}, node3: {node}}) + + def test_delayable_delay_group(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + DelayableGroup(node, node2, node3).delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies({node: {}, node2: {}, node3: {}}) + + def test_group_function(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + group(node, node2, node3).delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies({node: {}, node2: {}, node3: {}}) + + def test_delayable_delay_job_after_group(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + DelayableGroup(node, node2).on_done(node3).delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies({node: {}, node2: {}, node3: {node, node2}}) + + def test_delayable_delay_group_after_group(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + g1 = DelayableGroup(node, node2) + g2 = DelayableGroup(node3, node4) + g1.on_done(g2).delay() + self.assert_generated_job(node, node2, node3, node4) + self.assert_dependencies( + { + node: {}, + node2: {}, + node3: {node, node2}, + node4: {node, node2}, + } + ) + + def test_delayable_delay_implicit_group_after_group(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + g1 = DelayableGroup(node, node2).on_done(node3, node4) + g1.delay() + self.assert_generated_job(node, node2, node3, node4) + self.assert_dependencies( + { + node: {}, + node2: {}, + node3: {node, node2}, + node4: {node, node2}, + } + ) + + def test_delayable_delay_group_after_group_after_group(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + g1 = DelayableGroup(node) + g2 = DelayableGroup(node2) + g3 = DelayableGroup(node3) + g4 = DelayableGroup(node4) + g1.on_done(g2.on_done(g3.on_done(g4))).delay() + self.assert_generated_job(node, node2, node3, node4) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node2}, + node4: {node3}, + } + ) + + def test_delayable_diamond(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + g1 = DelayableGroup(node2, node3) + g1.on_done(node4) + node.on_done(g1) + node.delay() + self.assert_generated_job(node, node2, node3, node4) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node}, + node4: {node2, node3}, + } + ) + + def test_delayable_chain(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + c1 = DelayableChain(node, node2, node3) + c1.delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node2}, + } + ) + + def test_chain_function(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + c1 = chain(node, node2, node3) + c1.delay() + self.assert_generated_job(node, node2, node3) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node2}, + } + ) + + def test_delayable_chain_after_job(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + c1 = DelayableChain(node2, node3, node4) + node.on_done(c1) + node.delay() + self.assert_generated_job(node, node2, node3, node4) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node2}, + node4: {node3}, + } + ) + + def test_delayable_chain_after_chain(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + node5 = self.job_node(5) + node6 = self.job_node(6) + chain1 = DelayableChain(node, node2, node3) + chain2 = DelayableChain(node4, node5, node6) + chain1.on_done(chain2) + chain1.delay() + self.assert_generated_job(node, node2, node3, node4, node5, node6) + self.assert_dependencies( + { + node: {}, + node2: {node}, + node3: {node2}, + node4: {node3}, + node5: {node4}, + node6: {node5}, + } + ) + + def test_delayable_group_of_chain(self): + node = self.job_node(1) + node2 = self.job_node(2) + node3 = self.job_node(3) + node4 = self.job_node(4) + node5 = self.job_node(5) + node6 = self.job_node(6) + node7 = self.job_node(7) + node8 = self.job_node(8) + chain1 = DelayableChain(node, node2) + chain2 = DelayableChain(node3, node4) + chain3 = DelayableChain(node5, node6) + chain4 = DelayableChain(node7, node8) + g1 = DelayableGroup(chain1, chain2).on_done(chain3, chain4) + g1.delay() + self.assert_generated_job( + node, + node2, + node3, + node4, + node5, + node6, + node7, + node8, + ) + self.assert_dependencies( + { + node: {}, + node3: {}, + node2: {node}, + node4: {node3}, + node5: {node4, node2}, + node7: {node4, node2}, + node6: {node5}, + node8: {node7}, + } + ) + + def test_log_not_delayed(self): + with self.assertLogs(level=logging.WARNING) as test: + # When a Delayable never gets a delay() call, + # when the GC collects it and calls __del__, a warning + # will be displayed. + node = self.job_node(1) + expected = ( + "WARNING:odoo.addons.queue_job.delay:Delayable " + "Delayable(test.queue.job().testing_method((1,), {}))" + " was prepared but never delayed" + ) + self.assertFalse(node._generated_job) + + # Remove reference + del node + # Collect garbage using gc + gc.collect() + + self.assertEqual(test.output, [expected]) + + def test_delay_job_already_exists(self): + node = self.job_node(1) + node2 = self.job_node(2) + node2.delay() + node.on_done(node2).delay() + self.assert_generated_job(node, node2) + self.assert_dependencies({node: {}, node2: {node}}) diff --git a/test_queue_job/tests/test_dependencies.py b/test_queue_job/tests/test_dependencies.py new file mode 100644 index 0000000000..39b6928024 --- /dev/null +++ b/test_queue_job/tests/test_dependencies.py @@ -0,0 +1,302 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo.tests import common + +from odoo.addons.queue_job.delay import DelayableGraph, chain, group +from odoo.addons.queue_job.job import PENDING, WAIT_DEPENDENCIES, Job + + +class TestJobDependencies(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.queue_job = cls.env["queue.job"] + cls.method = cls.env["test.queue.job"].testing_method + + def test_depends_store(self): + job_root = Job(self.method) + job_lvl1_a = Job(self.method) + job_lvl1_a.add_depends({job_root}) + job_lvl1_b = Job(self.method) + job_lvl1_b.add_depends({job_root}) + job_lvl2_a = Job(self.method) + job_lvl2_a.add_depends({job_lvl1_a}) + + # Jobs must be stored after the dependencies are set up. + # (Or if not, a new store must be called on the parent) + job_root.store() + job_lvl1_a.store() + job_lvl1_b.store() + job_lvl2_a.store() + + # test properties + self.assertFalse(job_root.depends_on) + + self.assertEqual(job_lvl1_a.depends_on, {job_root}) + self.assertEqual(job_lvl1_b.depends_on, {job_root}) + + self.assertEqual(job_lvl2_a.depends_on, {job_lvl1_a}) + + self.assertEqual(job_root.reverse_depends_on, {job_lvl1_a, job_lvl1_b}) + + self.assertEqual(job_lvl1_a.reverse_depends_on, {job_lvl2_a}) + self.assertFalse(job_lvl1_b.reverse_depends_on) + + self.assertFalse(job_lvl2_a.reverse_depends_on) + + # test DB state + self.assertEqual(job_root.db_record().dependencies["depends_on"], []) + self.assertEqual( + sorted(job_root.db_record().dependencies["reverse_depends_on"]), + sorted([job_lvl1_a.uuid, job_lvl1_b.uuid]), + ) + + self.assertEqual( + job_lvl1_a.db_record().dependencies["depends_on"], [job_root.uuid] + ) + self.assertEqual( + job_lvl1_a.db_record().dependencies["reverse_depends_on"], [job_lvl2_a.uuid] + ) + + self.assertEqual( + job_lvl1_b.db_record().dependencies["depends_on"], [job_root.uuid] + ) + self.assertEqual(job_lvl1_b.db_record().dependencies["reverse_depends_on"], []) + + self.assertEqual( + job_lvl2_a.db_record().dependencies["depends_on"], [job_lvl1_a.uuid] + ) + self.assertEqual(job_lvl2_a.db_record().dependencies["reverse_depends_on"], []) + + def test_depends_store_after(self): + job_root = Job(self.method) + job_root.store() + job_a = Job(self.method) + job_a.add_depends({job_root}) + job_a.store() + + # as the reverse dependency has been added after the root job has been + # stored, it is not reflected in DB + self.assertEqual(job_root.db_record().dependencies["reverse_depends_on"], []) + + # a new store will write it + job_root.store() + self.assertEqual( + job_root.db_record().dependencies["reverse_depends_on"], [job_a.uuid] + ) + + def test_depends_load(self): + job_root = Job(self.method) + job_a = Job(self.method) + job_a.add_depends({job_root}) + + job_root.store() + job_a.store() + + read_job_root = Job.load(self.env, job_root.uuid) + self.assertEqual(read_job_root.reverse_depends_on, {job_a}) + + read_job_a = Job.load(self.env, job_a.uuid) + self.assertEqual(read_job_a.depends_on, {job_root}) + + def test_depends_enqueue_waiting_single(self): + job_root = Job(self.method) + job_a = Job(self.method) + job_a.add_depends({job_root}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_a]) + + job_root.store() + job_a.store() + + self.assertEqual(job_a.state, WAIT_DEPENDENCIES) + + # these are the steps run by RunJobController + job_root.perform() + job_root.set_done() + job_root.store() + self.env.flush_all() + + job_root.enqueue_waiting() + + # Will be picked up by the jobrunner. + # Warning: as the state has been changed in memory but + # not in the job_a instance, here, we re-read it. + # In practice, it won't be an issue for the jobrunner. + self.assertEqual(Job.load(self.env, job_a.uuid).state, PENDING) + + def test_dependency_graph(self): + job_root = Job(self.method) + job_lvl1_a = Job(self.method) + job_lvl1_a.add_depends({job_root}) + job_lvl1_b = Job(self.method) + job_lvl1_b.add_depends({job_root}) + job_lvl2_a = Job(self.method) + job_lvl2_a.add_depends({job_lvl1_a}) + + DelayableGraph._ensure_same_graph_uuid( + [ + job_root, + job_lvl1_a, + job_lvl1_b, + job_lvl2_a, + ] + ) + + job_2_root = Job(self.method) + job_2_child = Job(self.method) + job_2_child.add_depends({job_2_root}) + + DelayableGraph._ensure_same_graph_uuid([job_2_root, job_2_child]) + + # Jobs must be stored after the dependencies are set up. + # (Or if not, a new store must be called on the parent) + job_root.store() + job_lvl1_a.store() + job_lvl1_b.store() + job_lvl2_a.store() + + job_2_root.store() + job_2_child.store() + + record_root = job_root.db_record() + record_lvl1_a = job_lvl1_a.db_record() + record_lvl1_b = job_lvl1_b.db_record() + record_lvl2_a = job_lvl2_a.db_record() + + record_2_root = job_2_root.db_record() + record_2_child = job_2_child.db_record() + + expected_nodes = [ + { + "id": record_root.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + { + "id": record_lvl1_a.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + { + "id": record_lvl1_b.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + { + "id": record_lvl2_a.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + ] + expected_edges = sorted( + [ + [record_root.id, record_lvl1_a.id], + [record_lvl1_a.id, record_lvl2_a.id], + [record_root.id, record_lvl1_b.id], + ] + ) + + records = [record_root, record_lvl1_a, record_lvl1_b, record_lvl2_a] + + for record in records: + self.assertEqual( + sorted(record.dependency_graph["nodes"], key=lambda d: d["id"]), + expected_nodes, + ) + self.assertEqual(sorted(record.dependency_graph["edges"]), expected_edges) + + expected_nodes = [ + { + "id": record_2_root.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + { + "id": record_2_child.id, + "title": "Method used for tests
" + "test.queue.job().testing_method()", + "color": "#D2E5FF", + "border": "#2B7CE9", + "shadow": True, + }, + ] + expected_edges = sorted([[record_2_root.id, record_2_child.id]]) + + for record in [record_2_root, record_2_child]: + self.assertEqual( + sorted(record.dependency_graph["nodes"], key=lambda d: d["id"]), + expected_nodes, + ) + self.assertEqual(sorted(record.dependency_graph["edges"]), expected_edges) + + def test_no_dependency_graph_single_job(self): + """A single job has no graph""" + job = self.env["test.queue.job"].with_delay().testing_method() + self.assertEqual(job.db_record().dependency_graph, {}) + self.assertIsNone(job.graph_uuid) + + def test_depends_graph_uuid(self): + """All jobs in a graph share the same graph uuid""" + model = self.env["test.queue.job"] + delayable1 = model.delayable().testing_method(1) + delayable2 = model.delayable().testing_method(2) + delayable3 = model.delayable().testing_method(3) + delayable4 = model.delayable().testing_method(4) + group1 = group(delayable1, delayable2) + group2 = group(delayable3, delayable4) + chain_root = chain(group1, group2) + chain_root.delay() + + jobs = [ + delayable._generated_job + for delayable in [delayable1, delayable2, delayable3, delayable4] + ] + + self.assertTrue(jobs[0].graph_uuid) + self.assertEqual(len({j.graph_uuid for j in jobs}), 1) + for job in jobs: + self.assertEqual(job.graph_uuid, job.db_record().graph_uuid) + + def test_depends_graph_uuid_group(self): + """All jobs in a group share the same graph uuid""" + g = group( + self.env["test.queue.job"].delayable().testing_method(), + self.env["test.queue.job"].delayable().testing_method(), + ) + g.delay() + + jobs = [delayable._generated_job for delayable in g._delayables] + + self.assertTrue(jobs[0].graph_uuid) + self.assertTrue(jobs[1].graph_uuid) + self.assertEqual(jobs[0].graph_uuid, jobs[1].graph_uuid) + + def test_should_check_dependents(self): + job_root = Job(self.method) + job_a = Job(self.method) + job_a.add_depends({job_root}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_a]) + + job_root.store() + job_a.store() + + self.assertTrue(job_root.should_check_dependents()) + self.assertFalse(job_a.should_check_dependents()) diff --git a/test_queue_job/tests/test_job.py b/test_queue_job/tests/test_job.py new file mode 100644 index 0000000000..15b276fec4 --- /dev/null +++ b/test_queue_job/tests/test_job.py @@ -0,0 +1,1025 @@ +# Copyright 2016 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) +# ruff: noqa: DTZ001, DTZ005 + +import hashlib +from datetime import datetime, timedelta +from unittest import mock + +from odoo import Command +from odoo.tests import common + +from odoo.addons.queue_job import identity_exact +from odoo.addons.queue_job.controllers.main import RunJobController +from odoo.addons.queue_job.delay import DelayableGraph +from odoo.addons.queue_job.exception import ( + FailedJobError, + NoSuchJobError, + RetryableJobError, +) +from odoo.addons.queue_job.job import ( + CANCELLED, + DONE, + ENQUEUED, + FAILED, + PENDING, + RETRY_INTERVAL, + STARTED, + WAIT_DEPENDENCIES, + Job, +) + +from .common import JobCommonCase + + +class TestJobsOnTestingMethod(JobCommonCase): + """Test Job""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + main_company = cls.env.ref("base.main_company") + group_user = cls.env.ref("base.group_user") + cls.demo_user = cls.env["res.users"].create( + { + "name": "Demo User (Queue)", + "login": "queue_demo_user_3", + "company_id": main_company.id, + "company_ids": [Command.set([main_company.id])], + "group_ids": [Command.set([group_user.id])], + } + ) + + def test_new_job(self): + """ + Create a job + """ + test_job = Job(self.method) + self.assertEqual(test_job.func.__func__, self.method.__func__) + + def test_eta(self): + """When an `eta` is datetime, it uses it""" + now = datetime.now() + method = self.env["res.users"].mapped + job_a = Job(method, eta=now) + self.assertEqual(job_a.eta, now) + + def test_eta_integer(self): + """When an `eta` is an integer, it adds n seconds up to now""" + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + job_a = Job(self.method, eta=60) + self.assertEqual(job_a.eta, datetime(2015, 3, 15, 16, 42, 0)) + + def test_eta_timedelta(self): + """When an `eta` is a timedelta, it adds it up to now""" + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + delta = timedelta(hours=3) + job_a = Job(self.method, eta=delta) + self.assertEqual(job_a.eta, datetime(2015, 3, 15, 19, 41, 0)) + + def test_perform_args(self): + test_job = Job(self.method, args=("o", "k"), kwargs={"c": "!"}) + result = test_job.perform() + self.assertEqual(result, (("o", "k"), {"c": "!"})) + + def test_allow_commit_rebinds_recordsets_in_args(self): + record = self.env.user.partner_id + job = ( + self.env["test.queue.job"] + .with_delay() + .job_commit_with_arg_records(record, [record], {"record": record}, "ok") + ) + RunJobController._runjob(self.env, job) + self.assertEqual(job.state, DONE) + self.assertEqual(job.result, "ok") + + def test_retryable_error(self): + test_job = Job(self.method, kwargs={"raise_retry": True}, max_retries=3) + self.assertEqual(test_job.retry, 0) + with self.assertRaises(RetryableJobError): + test_job.perform() + self.assertEqual(test_job.retry, 1) + with self.assertRaises(RetryableJobError): + test_job.perform() + self.assertEqual(test_job.retry, 2) + with self.assertRaises(FailedJobError): + test_job.perform() + self.assertEqual(test_job.retry, 3) + + def test_infinite_retryable_error(self): + test_job = Job(self.method, kwargs={"raise_retry": True}, max_retries=0) + self.assertEqual(test_job.retry, 0) + with self.assertRaises(RetryableJobError): + test_job.perform() + self.assertEqual(test_job.retry, 1) + + def test_on_instance_method(self): + class A: + def method(self): + pass + + with self.assertRaises(TypeError): + Job(A.method) + + def test_on_model_method(self): + job_ = Job(self.env["test.queue.job"].testing_method) + self.assertEqual(job_.model_name, "test.queue.job") + self.assertEqual(job_.method_name, "testing_method") + + def test_invalid_function(self): + with self.assertRaises(TypeError): + Job(1) + + def test_set_pending(self): + job_a = Job(self.method) + job_a.set_pending(result="test") + self.assertEqual(job_a.state, PENDING) + self.assertFalse(job_a.date_enqueued) + self.assertFalse(job_a.date_started) + self.assertEqual(job_a.retry, 0) + self.assertEqual(job_a.result, "test") + + def test_set_enqueued(self): + job_a = Job(self.method) + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + job_a.set_enqueued() + + self.assertEqual(job_a.state, ENQUEUED) + self.assertEqual(job_a.date_enqueued, datetime(2015, 3, 15, 16, 41, 0)) + self.assertFalse(job_a.date_started) + + def test_set_started(self): + job_a = Job(self.method) + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + job_a.set_started() + + self.assertEqual(job_a.state, STARTED) + self.assertEqual(job_a.date_started, datetime(2015, 3, 15, 16, 41, 0)) + + def test_worker_pid(self): + """When a job is started, it gets the PID of the worker that starts it""" + method = self.env["res.users"].mapped + job_a = Job(method) + self.assertFalse(job_a.worker_pid) + with mock.patch("os.getpid", autospec=True) as mock_getpid: + mock_getpid.return_value = 99999 + job_a.set_started() + self.assertEqual(job_a.worker_pid, 99999) + + # reset the pid + job_a.set_pending() + self.assertFalse(job_a.worker_pid) + + def test_set_done(self): + job_a = Job(self.method) + job_a.date_started = datetime(2015, 3, 15, 16, 40, 0) + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + job_a.set_done(result="test") + + self.assertEqual(job_a.state, DONE) + self.assertEqual(job_a.result, "test") + self.assertEqual(job_a.date_done, datetime(2015, 3, 15, 16, 41, 0)) + self.assertEqual(job_a.exec_time, 60.0) + self.assertFalse(job_a.exc_info) + + def test_set_failed(self): + job_a = Job(self.method) + job_a.set_failed( + exc_info="failed test", + exc_name="FailedTest", + exc_message="Sadly this job failed", + ) + self.assertEqual(job_a.state, FAILED) + self.assertEqual(job_a.exc_info, "failed test") + self.assertEqual(job_a.exc_name, "FailedTest") + self.assertEqual(job_a.exc_message, "Sadly this job failed") + + def test_postpone(self): + job_a = Job(self.method) + datetime_path = "odoo.addons.queue_job.job.datetime" + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 3, 15, 16, 41, 0) + job_a.postpone(result="test", seconds=60) + + self.assertEqual(job_a.eta, datetime(2015, 3, 15, 16, 42, 0)) + self.assertEqual(job_a.result, "test") + self.assertFalse(job_a.exc_info) + + def test_company_simple(self): + company = self.env.ref("base.main_company") + eta = datetime.now() + timedelta(hours=5) + test_job = Job( + self.env["test.queue.job"].with_company(company).testing_method, + args=("o", "k"), + kwargs={"return_context": 1}, + priority=15, + eta=eta, + description="My description", + ) + test_job.worker_pid = 99999 # normally set on "set_start" + test_job.store() + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(test_job.func.__func__, job_read.func.__func__) + result_ctx = job_read.func(*tuple(test_job.args), **test_job.kwargs) + self.assertEqual(job_read.company_id, company.id) + # since 20.0, with_company() leaves the context unchanged for the + # current company + self.assertNotIn("allowed_company_ids", result_ctx) + + def test_company_complex(self): + company1 = self.env.ref("base.main_company") + company2 = company1.create({"name": "Queue job company"}) + companies = company1 | company2 + self.env.user.write({"company_ids": [(6, False, companies.ids)]}) + # Ensure the main company still the first + self.assertEqual(self.env.user.company_id, company1) + eta = datetime.now() + timedelta(hours=5) + test_job = Job( + self.env["test.queue.job"].with_company(company2).testing_method, + args=("o", "k"), + kwargs={"return_context": 1}, + priority=15, + eta=eta, + description="My description", + ) + test_job.worker_pid = 99999 # normally set on "set_start" + test_job.store() + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(test_job.func.__func__, job_read.func.__func__) + result_ctx = job_read.func(*tuple(test_job.args), **test_job.kwargs) + # since 20.0, with_company() keeps the other allowed companies + self.assertEqual( + result_ctx.get("allowed_company_ids"), (company2 | company1).ids + ) + + def test_store(self): + test_job = Job(self.method) + test_job.store() + stored = self.queue_job.search([("uuid", "=", test_job.uuid)]) + self.assertEqual(len(stored), 1) + + def test_store_extra_data(self): + test_job = Job(self.method) + test_job.store() + stored = self.queue_job.search([("uuid", "=", test_job.uuid)]) + self.assertEqual(stored.additional_info, "JUST_TESTING") + test_job.set_failed(exc_info="failed test", exc_name="FailedTest") + test_job.store() + stored.invalidate_recordset() + self.assertEqual(stored.additional_info, "JUST_TESTING_BUT_FAILED") + + def test_read(self): + eta = datetime.now() + timedelta(hours=5) + test_job = Job( + self.method, + args=("o", "k"), + kwargs={"c": "!"}, + priority=15, + eta=eta, + description="My description", + ) + test_job.worker_pid = 99999 # normally set on "set_start" + test_job.company_id = self.env.ref("base.main_company").id + test_job.store() + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(test_job.uuid, job_read.uuid) + self.assertEqual(test_job.model_name, job_read.model_name) + self.assertEqual(test_job.func.__func__, job_read.func.__func__) + self.assertEqual(test_job.args, job_read.args) + self.assertEqual(test_job.kwargs, job_read.kwargs) + self.assertEqual(test_job.method_name, job_read.method_name) + self.assertEqual(test_job.description, job_read.description) + self.assertEqual(test_job.state, job_read.state) + self.assertEqual(test_job.priority, job_read.priority) + self.assertEqual(test_job.exc_info, job_read.exc_info) + self.assertEqual(test_job.result, job_read.result) + self.assertEqual(test_job.user_id, job_read.user_id) + self.assertEqual(test_job.company_id, job_read.company_id) + self.assertEqual(test_job.worker_pid, 99999) + delta = timedelta(seconds=1) # DB does not keep milliseconds + self.assertAlmostEqual( + test_job.date_created, job_read.date_created, delta=delta + ) + self.assertAlmostEqual( + test_job.date_started, job_read.date_started, delta=delta + ) + self.assertAlmostEqual( + test_job.date_enqueued, job_read.date_enqueued, delta=delta + ) + self.assertAlmostEqual(test_job.date_done, job_read.date_done, delta=delta) + self.assertAlmostEqual(test_job.eta, job_read.eta, delta=delta) + + test_date = datetime(2015, 3, 15, 21, 7, 0) + job_read.date_enqueued = test_date + job_read.date_started = test_date + job_read.date_done = test_date + job_read.store() + + job_read = Job.load(self.env, test_job.uuid) + self.assertAlmostEqual(job_read.date_started, test_date, delta=delta) + self.assertAlmostEqual(job_read.date_enqueued, test_date, delta=delta) + self.assertAlmostEqual(job_read.date_done, test_date, delta=delta) + self.assertAlmostEqual(job_read.exec_time, 0.0) + + def test_job_unlinked(self): + test_job = Job(self.method, args=("o", "k"), kwargs={"c": "!"}) + test_job.store() + stored = self.queue_job.search([("uuid", "=", test_job.uuid)]) + stored.unlink() + with self.assertRaises(NoSuchJobError): + Job.load(self.env, test_job.uuid) + + def test_unicode(self): + test_job = Job( + self.method, + args=("öô¿‽", "ñě"), + kwargs={"c": "ßø"}, + priority=15, + description="My dé^Wdescription", + ) + test_job.store() + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(test_job.args, job_read.args) + self.assertEqual(job_read.args, ("öô¿‽", "ñě")) + self.assertEqual(test_job.kwargs, job_read.kwargs) + self.assertEqual(job_read.kwargs, {"c": "ßø"}) + self.assertEqual(test_job.description, job_read.description) + self.assertEqual(job_read.description, "My dé^Wdescription") + + def test_accented_bytestring(self): + test_job = Job( + self.method, + args=("öô¿‽", "ñě"), + kwargs={"c": "ßø"}, + priority=15, + description="My dé^Wdescription", + ) + test_job.store() + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(job_read.args, ("öô¿‽", "ñě")) + self.assertEqual(job_read.kwargs, {"c": "ßø"}) + self.assertEqual(job_read.description, "My dé^Wdescription") + + def test_job_delay(self): + self.cr.execute("delete from queue_job") + job_ = self.env["test.queue.job"].with_delay().testing_method() + stored = self.queue_job.search([]) + self.assertEqual(len(stored), 1) + self.assertEqual(stored.uuid, job_.uuid, "Incorrect returned Job UUID") + + def test_job_delay_model_method(self): + self.cr.execute("delete from queue_job") + delayable = self.env["test.queue.job"].with_delay() + job_instance = delayable.testing_method("a", k=1) + self.assertTrue(job_instance) + result = job_instance.perform() + self.assertEqual(result, (("a",), {"k": 1})) + + def test_job_identity_key_str(self): + id_key = "e294e8444453b09d59bdb6efbfec1323" + test_job_1 = Job( + self.method, + priority=15, + description="Test I am the first one", + identity_key=id_key, + ) + test_job_1.store() + job1 = Job.load(self.env, test_job_1.uuid) + self.assertEqual(job1.identity_key, id_key) + + def test_job_identity_key_func_exact(self): + hasher = hashlib.sha1() + hasher.update(b"test.queue.job") + hasher.update(b"testing_method") + hasher.update(str(sorted([])).encode("utf-8")) + hasher.update(str((1, "foo")).encode("utf-8")) + hasher.update(str(sorted({"bar": "baz"}.items())).encode("utf-8")) + expected_key = hasher.hexdigest() + + test_job_1 = Job( + self.method, + args=[1, "foo"], + kwargs={"bar": "baz"}, + identity_key=identity_exact, + ) + self.assertEqual(test_job_1.identity_key, expected_key) + test_job_1.store() + + job1 = Job.load(self.env, test_job_1.uuid) + self.assertEqual(job1.identity_key, expected_key) + + +class TestJobs(JobCommonCase): + """Test jobs on other methods or with different job configuration""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + main_company = cls.env.ref("base.main_company") + group_user = cls.env.ref("base.group_user") + cls.demo_user = cls.env["res.users"].create( + { + "name": "Demo User (Queue)", + "login": "queue_demo_user_4", + "company_id": main_company.id, + "company_ids": [Command.set([main_company.id])], + "group_ids": [Command.set([group_user.id])], + } + ) + + def test_description(self): + """If no description is given to the job, it + should be computed from the function + """ + # if a docstring is defined for the function + # it's used as description + job_a = Job(self.env["test.queue.job"].testing_method) + self.assertEqual(job_a.description, "Method used for tests") + # if no docstring, the description is computed + job_b = Job(self.env["test.queue.job"].no_description) + self.assertEqual(job_b.description, "test.queue.job.no_description") + # case when we explicitly specify the description + description = "My description" + job_a = Job(self.env["test.queue.job"].testing_method, description=description) + self.assertEqual(job_a.description, description) + + def test_retry_pattern(self): + """When we specify a retry pattern, the eta must follow it""" + datetime_path = "odoo.addons.queue_job.job.datetime" + method = self.env["test.queue.job"].job_with_retry_pattern + with mock.patch(datetime_path, autospec=True) as mock_datetime: + mock_datetime.now.return_value = datetime(2015, 6, 1, 15, 10, 0) + test_job = Job(method, max_retries=0) + test_job.retry += 1 + test_job.postpone(self.env) + self.assertEqual(test_job.retry, 1) + self.assertEqual(test_job.eta, datetime(2015, 6, 1, 15, 11, 0)) + test_job.retry += 1 + test_job.postpone(self.env) + self.assertEqual(test_job.retry, 2) + self.assertEqual(test_job.eta, datetime(2015, 6, 1, 15, 13, 0)) + test_job.retry += 1 + test_job.postpone(self.env) + self.assertEqual(test_job.retry, 3) + self.assertEqual(test_job.eta, datetime(2015, 6, 1, 15, 10, 10)) + test_job.retry += 1 + test_job.postpone(self.env) + self.assertEqual(test_job.retry, 4) + self.assertEqual(test_job.eta, datetime(2015, 6, 1, 15, 10, 10)) + test_job.retry += 1 + test_job.postpone(self.env) + self.assertEqual(test_job.retry, 5) + self.assertEqual(test_job.eta, datetime(2015, 6, 1, 15, 15, 0)) + + def test_retry_pattern_no_zero(self): + """When we specify a retry pattern without 0, uses RETRY_INTERVAL""" + method = self.env["test.queue.job"].job_with_retry_pattern__no_zero + test_job = Job(method, max_retries=0) + test_job.retry += 1 + self.assertEqual(test_job.retry, 1) + self.assertEqual(test_job._get_retry_seconds(), RETRY_INTERVAL) + test_job.retry += 1 + self.assertEqual(test_job.retry, 2) + self.assertEqual(test_job._get_retry_seconds(), RETRY_INTERVAL) + test_job.retry += 1 + self.assertEqual(test_job.retry, 3) + self.assertEqual(test_job._get_retry_seconds(), 180) + test_job.retry += 1 + self.assertEqual(test_job.retry, 4) + self.assertEqual(test_job._get_retry_seconds(), 180) + + def test_job_delay_model_method_multi(self): + rec1 = self.env["test.queue.job"].create({"name": "test1"}) + rec2 = self.env["test.queue.job"].create({"name": "test2"}) + recs = rec1 + rec2 + job_instance = recs.with_delay().mapped("name") + self.assertTrue(job_instance) + self.assertEqual(job_instance.args, ("name",)) + self.assertEqual(job_instance.recordset, recs) + self.assertEqual(job_instance.model_name, "test.queue.job") + self.assertEqual(job_instance.method_name, "mapped") + self.assertEqual(["test1", "test2"], job_instance.perform()) + + def test_job_identity_key_no_duplicate(self): + """If a job with same identity key in queue do not add a new one""" + id_key = "e294e8444453b09d59bdb6efbfec1323" + rec1 = self.env["test.queue.job"].create({"name": "test1"}) + job_1 = rec1.with_delay(identity_key=id_key).mapped("name") + + self.assertTrue(job_1) + job_2 = rec1.with_delay(identity_key=id_key).mapped("name") + self.assertEqual(job_2.uuid, job_1.uuid) + + def test_job_with_mutable_arguments(self): + """Job with mutable arguments do not mutate on perform()""" + delayable = self.env["test.queue.job"].with_delay() + job_instance = delayable.job_alter_mutable([1], mutable_kwarg={"a": 1}) + self.assertTrue(job_instance) + result = job_instance.perform() + self.assertEqual(result, ([1, 2], {"a": 1, "b": 2})) + job_instance.set_done() + # at this point, the 'args' and 'kwargs' of the job instance + # might have been modified, but they must never be modified in + # the queue_job table after their creation, so a new 'load' will + # get the initial values. + job_instance.store() + # jobs are always loaded before being performed, so we simulate + # this behavior here to check if we have the correct initial arguments + job_instance = Job.load(self.env, job_instance.uuid) + self.assertEqual(([1],), job_instance.args) + self.assertEqual({"mutable_kwarg": {"a": 1}}, job_instance.kwargs) + + def test_store_env_su_no_sudo(self): + demo_user = self.demo_user + self.env = self.env(user=demo_user) + delayable = self.env["test.queue.job"].with_delay() + test_job = delayable.testing_method() + stored = test_job.db_record() + job_instance = Job.load(self.env, stored.uuid) + self.assertFalse(job_instance.recordset.env.su) + self.assertTrue(job_instance.user_id, demo_user) + + def test_store_env_su_sudo(self): + demo_user = self.demo_user + self.env = self.env(user=demo_user) + delayable = self.env["test.queue.job"].sudo().with_delay() + test_job = delayable.testing_method() + stored = test_job.db_record() + job_instance = Job.load(self.env, stored.uuid) + self.assertTrue(job_instance.recordset.env.su) + self.assertTrue(job_instance.user_id, demo_user) + + +class TestJobModel(JobCommonCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + User = cls.env["res.users"] + main_company = cls.env.ref("base.main_company") + group_user = cls.env.ref("base.group_user") + cls.demo_user = User.create( + { + "name": "Demo User (Queue)", + "login": "queue_demo_user_5", + "company_id": main_company.id, + "company_ids": [Command.set([main_company.id])], + "group_ids": [Command.set([group_user.id])], + } + ) + + def test_job_change_state(self): + stored = self._create_job() + stored._change_job_state(DONE, result="test") + self.assertEqual(stored.state, DONE) + self.assertEqual(stored.result, "test") + stored._change_job_state(PENDING, result="test2") + self.assertEqual(stored.state, PENDING) + self.assertEqual(stored.result, "test2") + with self.assertRaises(ValueError): + # only PENDING and DONE supported + stored._change_job_state(STARTED) + + def test_button_done(self): + stored = self._create_job() + stored.button_done() + self.assertEqual(stored.state, DONE) + self.assertEqual(stored.result, f"Manually set to done by {self.env.user.name}") + + def test_button_done_enqueue_waiting_dependencies(self): + job_root = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_child]) + job_root.store() + job_child.store() + + self.assertEqual(job_child.state, WAIT_DEPENDENCIES) + record_root = job_root.db_record() + record_child = job_child.db_record() + # Trigger button done + record_root.button_done() + # Check the state + self.assertEqual(record_root.state, DONE) + self.assertEqual(record_child.state, PENDING) + + def test_button_cancel_dependencies(self): + job_root = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_child]) + job_root.store() + job_child.store() + + self.assertEqual(job_child.state, WAIT_DEPENDENCIES) + record_root = job_root.db_record() + record_child = job_child.db_record() + # Trigger button cancelled + record_root.button_cancelled() + # Check the state + self.assertEqual(record_root.state, CANCELLED) + self.assertEqual(record_child.state, CANCELLED) + self.assertTrue(record_child.date_cancelled) + + def test_button_cancel_dependencies_cascade(self): + """Cancelling a job cancels all its descendants. + + Scenario: + 1. Store a chain of three jobs: root -> child -> grandchild. + 2. Cancel the root job. + Expected: + - The child and the grandchild are cancelled too. + """ + job_root = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_grandchild = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root}) + job_grandchild.add_depends({job_child}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_child, job_grandchild]) + job_root.store() + job_child.store() + job_grandchild.store() + + record_root = job_root.db_record() + record_child = job_child.db_record() + record_grandchild = job_grandchild.db_record() + record_root.button_cancelled() + self.assertEqual(record_root.state, CANCELLED) + self.assertEqual(record_child.state, CANCELLED) + self.assertEqual(record_grandchild.state, CANCELLED) + self.assertEqual(record_grandchild.date_cancelled, record_root.date_cancelled) + self.assertEqual( + record_grandchild.result, + "Cancelled because a job it depends on was cancelled", + ) + + def test_button_cancel_dependencies_selected(self): + """Cancelling a job along with its dependent cancels the dependent once. + + Scenario: + 1. Store a job depending on another one. + 2. Select both jobs and cancel them. + Expected: + - The dependent is cancelled as a dependent of the first job. + """ + job_root = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root}) + + DelayableGraph._ensure_same_graph_uuid([job_root, job_child]) + job_root.store() + job_child.store() + + record_root = job_root.db_record() + record_child = job_child.db_record() + (record_root | record_child).button_cancelled() + self.assertEqual(record_child.state, CANCELLED) + self.assertEqual(record_child.date_cancelled, record_root.date_cancelled) + self.assertEqual( + record_child.result, + "Cancelled because a job it depends on was cancelled", + ) + + def test_button_cancel_dependencies_other_parent_done(self): + """Cancelling a parent cancels a child whose other parent is done. + + Scenario: + 1. Store a job depending on two parent jobs. + 2. Set the first parent to done. + 3. Cancel the second parent. + Expected: + - The child is cancelled. + """ + job_root_1 = Job(self.env["test.queue.job"].testing_method) + job_root_2 = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root_1, job_root_2}) + + DelayableGraph._ensure_same_graph_uuid([job_root_1, job_root_2, job_child]) + job_root_1.store() + job_root_2.store() + job_child.store() + + record_root_1 = job_root_1.db_record() + record_root_2 = job_root_2.db_record() + record_child = job_child.db_record() + record_root_1.button_done() + self.assertEqual(record_child.state, WAIT_DEPENDENCIES) + record_root_2.button_cancelled() + self.assertEqual(record_child.state, CANCELLED) + + def test_button_done_dependencies_other_parent_cancelled(self): + """Cancelling a parent cancels a child whose other parent is not done yet. + + Scenario: + 1. Store a job depending on two parent jobs. + 2. Cancel the first parent. + 3. Set the second parent to done. + Expected: + - The child is cancelled as soon as the first parent is. + - It stays cancelled once the second parent is done. + """ + job_root_1 = Job(self.env["test.queue.job"].testing_method) + job_root_2 = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root_1, job_root_2}) + + DelayableGraph._ensure_same_graph_uuid([job_root_1, job_root_2, job_child]) + job_root_1.store() + job_root_2.store() + job_child.store() + + record_root_1 = job_root_1.db_record() + record_root_2 = job_root_2.db_record() + record_child = job_child.db_record() + record_root_1.button_cancelled() + self.assertEqual(record_child.state, CANCELLED) + record_root_2.button_done() + self.assertEqual(record_child.state, CANCELLED) + + def test_search_dependencies(self): + """Jobs can be searched by their dependencies and dependents. + + Scenario: + 1. Store a job depending on two parent jobs. + 2. Set the first parent to failed. + Expected: + - The child is found from either parent, and the parents from the child. + - The child is found as waiting on a failed job, the parents are not. + """ + job_root_1 = Job(self.env["test.queue.job"].testing_method) + job_root_2 = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root_1, job_root_2}) + + DelayableGraph._ensure_same_graph_uuid([job_root_1, job_root_2, job_child]) + job_root_1.store() + job_root_2.store() + job_child.store() + + record_root_1 = job_root_1.db_record() + record_root_2 = job_root_2.db_record() + record_child = job_child.db_record() + record_root_1.state = FAILED + job_model = self.env["queue.job"] + graph = [("graph_uuid", "=", job_child.graph_uuid)] + self.assertEqual( + job_model.search(graph + [("dependency_ids", "in", record_root_1.ids)]), + record_child, + ) + self.assertEqual( + job_model.search(graph + [("dependent_ids", "in", record_child.ids)]), + record_root_1 | record_root_2, + ) + self.assertEqual( + job_model.search( + graph + [("dependency_ids", "any", [("state", "=", FAILED)])] + ), + record_child, + ) + self.assertEqual( + job_model.search( + graph + [("dependency_ids", "not any", [("state", "=", FAILED)])] + ), + record_root_1 | record_root_2, + ) + + def test_requeue(self): + stored = self._create_job() + stored.write({"state": "failed"}) + stored.requeue() + self.assertEqual(stored.state, PENDING) + + def test_requeue_wait_dependencies_not_touched(self): + job_root = Job(self.env["test.queue.job"].testing_method) + job_child = Job(self.env["test.queue.job"].testing_method) + job_child.add_depends({job_root}) + job_root.store() + job_child.store() + + DelayableGraph._ensure_same_graph_uuid([job_root, job_child]) + + record_root = job_root.db_record() + record_child = job_child.db_record() + self.assertEqual(record_root.state, PENDING) + self.assertEqual(record_child.state, WAIT_DEPENDENCIES) + record_root.write({"state": "failed"}) + + (record_root + record_child).requeue() + self.assertEqual(record_root.state, PENDING) + self.assertEqual(record_child.state, WAIT_DEPENDENCIES) + + def test_message_when_write_fail(self): + stored = self._create_job() + stored.write({"state": "failed"}) + self.assertEqual(stored.state, FAILED) + messages = stored.message_ids + self.assertEqual(len(messages), 1) + + def test_follower_when_write_fail(self): + """Check that inactive users doesn't are not followers even if + they are linked to an active partner""" + group = self.env.ref("queue_job.group_queue_job_manager") + vals = { + "name": "xx", + "login": "xx", + "group_ids": [Command.set([group.id])], + "active": False, + } + inactiveusr = self.user.create(vals) + inactiveusr.partner_id.active = True + self.assertFalse(inactiveusr in group.user_ids) + stored = self._create_job() + stored.write({"state": "failed"}) + followers = stored.message_follower_ids.mapped("partner_id") + self.assertFalse(inactiveusr.partner_id in followers) + self.assertFalse({u.partner_id for u in group.user_ids} - set(followers)) + + def test_wizard_requeue(self): + stored = self._create_job() + stored.write({"state": "failed"}) + model = self.env["queue.requeue.job"] + model = model.with_context(active_model="queue.job", active_ids=stored.ids) + model.create({}).requeue() + self.assertEqual(stored.state, PENDING) + + def test_context_uuid(self): + delayable = self.env["test.queue.job"].with_delay() + test_job = delayable.testing_method(return_context=True) + result = test_job.perform() + key_present = "job_uuid" in result + self.assertTrue(key_present) + self.assertEqual(result["job_uuid"], test_job._uuid) + + def test_override_channel(self): + delayable = self.env["test.queue.job"].with_delay(channel="root.sub.sub") + test_job = delayable.testing_method(return_context=True) + self.assertEqual("root.sub.sub", test_job.channel) + + def test_job_change_user_id(self): + demo_user = self.demo_user + stored = self._create_job() + stored.user_id = demo_user + self.assertEqual(stored.records.env.uid, demo_user.id) + + +class TestJobStorageMultiCompany(common.TransactionCase): + """Test storage of jobs""" + + def setUp(self): + super().setUp() + self.queue_job = self.env["queue.job"] + grp_queue_job_manager = self.ref("queue_job.group_queue_job_manager") + User = self.env["res.users"] + Company = self.env["res.company"] + Partner = self.env["res.partner"] + + main_company = self.env.ref("base.main_company") + + self.partner_user = Partner.create( + {"name": "Simple User", "email": "simple.user@example.com"} + ) + self.simple_user = User.create( + { + "partner_id": self.partner_user.id, + "company_ids": [Command.link(main_company.id)], + "login": "simple_user", + "name": "simple user", + "group_ids": [], + } + ) + + self.other_partner_a = Partner.create( + {"name": "My Company a", "is_company": True, "email": "test@tes.ttest"} + ) + self.other_company_a = Company.create( + { + "name": "My Company a", + "partner_id": self.other_partner_a.id, + "currency_id": self.ref("base.EUR"), + } + ) + self.other_user_a = User.create( + { + "partner_id": self.other_partner_a.id, + "company_id": self.other_company_a.id, + "company_ids": [Command.link(self.other_company_a.id)], + "login": "my_login a", + "name": "my user A", + "group_ids": [Command.link(grp_queue_job_manager)], + } + ) + self.other_partner_b = Partner.create( + {"name": "My Company b", "is_company": True, "email": "test@tes.ttest"} + ) + self.other_company_b = Company.create( + { + "name": "My Company b", + "partner_id": self.other_partner_b.id, + "currency_id": self.ref("base.EUR"), + } + ) + self.other_user_b = User.create( + { + "partner_id": self.other_partner_b.id, + "company_id": self.other_company_b.id, + "company_ids": [Command.link(self.other_company_b.id)], + "login": "my_login_b", + "name": "my user B", + "group_ids": [Command.link(grp_queue_job_manager)], + } + ) + + def _create_job(self, env): + self.cr.execute("delete from queue_job") + env["test.queue.job"].with_delay().testing_method() + stored = self.queue_job.search([]) + self.assertEqual(len(stored), 1) + return stored + + def test_job_default_company_id(self): + """the default company is the one from the current user_id""" + stored = self._create_job(self.env) + self.assertEqual( + stored.company_id.id, + self.ref("base.main_company"), + "Incorrect default company_id", + ) + env = self.env(user=self.other_user_b.id) + stored = self._create_job(env) + self.assertEqual( + stored.company_id.id, + self.other_company_b.id, + "Incorrect default company_id", + ) + + def test_job_no_company_id(self): + """if we put an empty company_id in the context + jobs are created without company_id + """ + env = self.env(context={"company_id": None}) + stored = self._create_job(env) + self.assertFalse(stored.company_id, "Company_id should be empty") + + def test_job_specific_company_id(self): + """If a company_id specified in the context + it's used by default for the job creation""" + env = self.env(context={"company_id": self.other_company_a.id}) + stored = self._create_job(env) + self.assertEqual( + stored.company_id.id, self.other_company_a.id, "Incorrect company_id" + ) + + def test_job_subscription(self): + # if the job is created without company_id, all members of + # queue_job.group_queue_job_manager must be followers + User = self.env["res.users"] + no_company_context = dict(self.env.context, company_id=None) + no_company_env = self.env(user=self.simple_user, context=no_company_context) + stored = self._create_job(no_company_env) + stored._message_post_on_failure() + users = ( + User.search( + [("group_ids", "=", self.ref("queue_job.group_queue_job_manager"))] + ) + + stored.user_id + ) + self.assertEqual(len(stored.message_follower_ids), len(users)) + expected_partners = [u.partner_id for u in users] + self.assertSetEqual( + set(stored.message_follower_ids.mapped("partner_id")), + set(expected_partners), + ) + followers_id = stored.message_follower_ids.mapped("partner_id.id") + self.assertIn(self.other_partner_a.id, followers_id) + self.assertIn(self.other_partner_b.id, followers_id) + # jobs created for a specific company_id are followed only by + # company's members + company_a_context = dict(self.env.context, company_id=self.other_company_a.id) + company_a_env = self.env(user=self.simple_user, context=company_a_context) + stored = self._create_job(company_a_env) + stored.with_user(self.other_user_a.id) + stored._message_post_on_failure() + # 2 because simple_user (creator of job) + self.other_partner_a + self.assertEqual(len(stored.message_follower_ids), 2) + users = self.simple_user + self.other_user_a + expected_partners = [u.partner_id for u in users] + self.assertSetEqual( + set(stored.message_follower_ids.mapped("partner_id")), + set(expected_partners), + ) + followers_id = stored.message_follower_ids.mapped("partner_id.id") + self.assertIn(self.other_partner_a.id, followers_id) + self.assertNotIn(self.other_partner_b.id, followers_id) diff --git a/test_queue_job/tests/test_job_auto_delay.py b/test_queue_job/tests/test_job_auto_delay.py new file mode 100644 index 0000000000..56dbf16313 --- /dev/null +++ b/test_queue_job/tests/test_job_auto_delay.py @@ -0,0 +1,50 @@ +# Copyright 2020 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo.tests.common import tagged + +from odoo.addons.queue_job.job import Job + +from .common import JobCommonCase + + +@tagged("post_install", "-at_install") +class TestJobAutoDelay(JobCommonCase): + """Test auto delay of jobs""" + + def test_auto_delay(self): + """method decorated by @job_auto_delay is automatically delayed""" + result = self.env["test.queue.job"].delay_me(1, kwarg=2) + self.assertTrue(isinstance(result, Job)) + self.assertEqual(result.args, (1,)) + self.assertEqual(result.kwargs, {"kwarg": 2}) + + def test_auto_delay_options(self): + """method automatically delayed une _job_options arguments""" + result = self.env["test.queue.job"].delay_me_options() + self.assertTrue(isinstance(result, Job)) + self.assertEqual(result.identity_key, "my_job_identity") + + def test_auto_delay_inside_job(self): + """when a delayed job is processed, it must not delay itself""" + job_ = self.env["test.queue.job"].delay_me(1, kwarg=2) + self.assertTrue(job_.perform(), (1, 2)) + + def test_auto_delay_force_sync(self): + """method forced to run synchronously""" + result = self.env["test.queue.job"].delay_me(1, kwarg=2) + self.assertTrue(result, (1, 2)) + + def test_auto_delay_context_key_set(self): + """patched with context_key delays only if context keys is set""" + result = ( + self.env["test.queue.job"] + .with_context(auto_delay_delay_me_context_key=True) + .delay_me_context_key() + ) + self.assertTrue(isinstance(result, Job)) + + def test_auto_delay_context_key_unset(self): + """patched with context_key do not delay if context keys is not set""" + result = self.env["test.queue.job"].delay_me_context_key() + self.assertEqual(result, "ok") diff --git a/test_queue_job/tests/test_job_channels.py b/test_queue_job/tests/test_job_channels.py new file mode 100644 index 0000000000..663648e0c5 --- /dev/null +++ b/test_queue_job/tests/test_job_channels.py @@ -0,0 +1,93 @@ +# Copyright 2016 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo import exceptions +from odoo.tests import common + +from odoo.addons.queue_job.job import Job + + +class TestJobChannels(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.function_model = cls.env["queue.job.function"] + cls.channel_model = cls.env["queue.job.channel"] + cls.test_model = cls.env["test.queue.channel"] + cls.root_channel = cls.env.ref("queue_job.channel_root") + + def test_channel_complete_name(self): + channel = self.channel_model.create( + {"name": "number", "parent_id": self.root_channel.id} + ) + subchannel = self.channel_model.create( + {"name": "five", "parent_id": channel.id} + ) + self.assertEqual(channel.complete_name, "root.number") + self.assertEqual(subchannel.complete_name, "root.number.five") + + def test_channel_tree(self): + with self.assertRaises(exceptions.ValidationError): + self.channel_model.create({"name": "sub"}) + + def test_channel_root(self): + with self.assertRaises(exceptions.UserError): + self.root_channel.unlink() + with self.assertRaises(exceptions.UserError): + self.root_channel.name = "leaf" + + def test_channel_on_job(self): + method = self.env["test.queue.channel"].job_a + path_a = self.env["queue.job.function"].job_function_name( + "test.queue.channel", "job_a" + ) + job_func = self.function_model.search([("name", "=", path_a)]) + + self.assertEqual(job_func.channel, "root") + + test_job = Job(method) + test_job.store() + stored = test_job.db_record() + self.assertEqual(stored.channel, "root") + job_read = Job.load(self.env, test_job.uuid) + self.assertEqual(job_read.channel, "root") + + sub_channel = self.env.ref("test_queue_job.channel_sub") + job_func.channel_id = sub_channel + + test_job = Job(method) + test_job.store() + stored = test_job.db_record() + self.assertEqual(stored.channel, "root.sub") + + # it's also possible to override the channel + test_job = Job(method, channel="root.sub") + test_job.store() + stored = test_job.db_record() + self.assertEqual(stored.channel, test_job.channel) + + def test_default_channel_no_xml(self): + """Channel on job is root if there is no queue.job.function record""" + test_job = Job(self.env["res.users"].browse) + test_job.store() + stored = test_job.db_record() + self.assertEqual(stored.channel, "root") + + def test_set_channel_from_record(self): + func_name = self.env["queue.job.function"].job_function_name( + "test.queue.channel", "job_sub_channel" + ) + job_func = self.function_model.search([("name", "=", func_name)]) + self.assertEqual(job_func.channel, "root.sub.subsub") + + channel = job_func.channel_id + self.assertEqual(channel.name, "subsub") + self.assertEqual(channel.parent_id.name, "sub") + self.assertEqual(channel.parent_id.parent_id.name, "root") + self.assertEqual(job_func.channel, "root.sub.subsub") + + def test_default_removal_interval(self): + channel = self.channel_model.create( + {"name": "number", "parent_id": self.root_channel.id} + ) + self.assertEqual(channel.removal_interval, 30) diff --git a/test_queue_job/tests/test_job_function.py b/test_queue_job/tests/test_job_function.py new file mode 100644 index 0000000000..824ce902c2 --- /dev/null +++ b/test_queue_job/tests/test_job_function.py @@ -0,0 +1,35 @@ +from odoo import exceptions +from odoo.tests import common + + +class TestJobFunction(common.TransactionCase): + def setUp(self): + super().setUp() + self.test_function_model = self.env.ref( + "queue_job.job_function_queue_job__test_job" + ) + + def test_check_retry_pattern_randomized_case(self): + randomized_pattern = "{1: (10, 20), 2: (20, 40)}" + self.test_function_model.edit_retry_pattern = randomized_pattern + self.assertEqual( + self.test_function_model.edit_retry_pattern, randomized_pattern + ) + + def test_check_retry_pattern_fixed_case(self): + fixed_pattern = "{1: 10, 2: 20}" + self.test_function_model.edit_retry_pattern = fixed_pattern + self.assertEqual(self.test_function_model.edit_retry_pattern, fixed_pattern) + + def test_check_retry_pattern_invalid_cases(self): + invalid_time_value_pattern = "{1: a, 2: 20}" + with self.assertRaises(exceptions.UserError): + self.test_function_model.edit_retry_pattern = invalid_time_value_pattern + + invalid_retry_count_pattern = "{a: 10, 2: 20}" + with self.assertRaises(exceptions.UserError): + self.test_function_model.edit_retry_pattern = invalid_retry_count_pattern + + invalid_randomized_pattern = "{1: (1, 2, 3), 2: 20}" + with self.assertRaises(exceptions.UserError): + self.test_function_model.edit_retry_pattern = invalid_randomized_pattern diff --git a/test_queue_job/tests/test_json_field.py b/test_queue_job/tests/test_json_field.py new file mode 100644 index 0000000000..33b6bcdb97 --- /dev/null +++ b/test_queue_job/tests/test_json_field.py @@ -0,0 +1,48 @@ +# copyright 2022 Guewen Baconnier +# license lgpl-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +import json + +from odoo import Command +from odoo.tests import common + +# pylint: disable=odoo-addons-relative-import +# we are testing, we want to test as if we were an external consumer of the API +from odoo.addons.queue_job.fields import JobEncoder + + +class TestJsonField(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + User = cls.env["res.users"] + main_company = cls.env.ref("base.main_company") + group_user = cls.env.ref("base.group_user") + cls.demo_user = User.create( + { + "name": "Demo User (Queue)", + "login": "queue_demo_user_2", + "company_id": main_company.id, + "company_ids": [Command.set([main_company.id])], + "group_ids": [Command.set([group_user.id])], + } + ) + + # TODO: when migrating to 16.0, adapt checks in queue_job/tests/test_json_field.py + # to verify the context keys are encoded and remove these + def test_encoder_recordset_store_context(self): + demo_user = self.demo_user + user_context = {"lang": "en_US", "tz": "Europe/Brussels"} + test_model = self.env(user=demo_user, context=user_context)["test.queue.job"] + value_json = json.dumps(test_model, cls=JobEncoder) + self.assertEqual(json.loads(value_json)["context"], user_context) + + def test_encoder_recordset_context_filter_keys(self): + demo_user = self.demo_user + user_context = {"lang": "en_US", "tz": "Europe/Brussels"} + tampered_context = dict(user_context, foo=object()) + test_model = self.env(user=demo_user, context=tampered_context)[ + "test.queue.job" + ] + value_json = json.dumps(test_model, cls=JobEncoder) + self.assertEqual(json.loads(value_json)["context"], user_context) diff --git a/test_queue_job/tests/test_related_actions.py b/test_queue_job/tests/test_related_actions.py new file mode 100644 index 0000000000..159439f9af --- /dev/null +++ b/test_queue_job/tests/test_related_actions.py @@ -0,0 +1,114 @@ +# Copyright 2014-2016 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo import exceptions +from odoo.tests import common + + +class TestRelatedAction(common.TransactionCase): + """Test Related Actions""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.model = cls.env["test.related.action"] + cls.record = cls.model.create({}) + cls.records = cls.record + cls.model.create({}) + + def test_attributes(self): + """Job with related action check if action returns correctly""" + job_ = self.record.with_delay().testing_related_action__kwargs() + act_job, act_kwargs = job_.related_action() + self.assertEqual(act_job, job_.db_record()) + self.assertEqual(act_kwargs, {"b": 4}) + + def test_decorator_empty(self): + """Job with decorator without value disable the default action + + The ``related_action`` configuration is: ``{"enable": False}`` + """ + # default action returns None + job_ = self.record.with_delay().testing_related_action__return_none() + self.assertIsNone(job_.related_action()) + + def test_model_no_action(self): + """Model shows an error when no action exist""" + job_ = self.record.with_delay().testing_related_action__return_none() + with self.assertRaises(exceptions.UserError): + # db_record is the 'job.queue' record on which we click on the + # button to open the related action + job_.db_record().open_related_action() + + def test_default_no_record(self): + """Default related action called when no decorator is set + + When called on no record. + + The ``related_action`` configuration is: ``{}`` + """ + job_ = self.model.with_delay().testing_related_action__no() + expected = None + self.assertEqual(job_.related_action(), expected) + + def test_model_default_no_record(self): + """Model shows an error when using the default action and we have no + record linke to the job""" + job_ = self.model.with_delay().testing_related_action__no() + with self.assertRaises(exceptions.UserError): + # db_record is the 'job.queue' record on which we click on the + # button to open the related action + job_.db_record().open_related_action() + + def test_default_one_record(self): + """Default related action called when no decorator is set + + When called on one record. + + The ``related_action`` configuration is: ``{}`` + """ + job_ = self.record.with_delay().testing_related_action__no() + expected = { + "name": "Related Record", + "res_id": self.record.id, + "res_model": self.record._name, + "type": "ir.actions.act_window", + "view_mode": "form", + } + self.assertEqual(job_.related_action(), expected) + + def test_default_several_record(self): + """Default related action called when no decorator is set + + When called on several record. + + The ``related_action`` configuration is: ``{}`` + """ + job_ = self.records.with_delay().testing_related_action__no() + expected = { + "name": "Related Records", + "domain": [("id", "in", self.records.ids)], + "res_model": self.record._name, + "type": "ir.actions.act_window", + "view_mode": "list,form", + } + self.assertEqual(job_.related_action(), expected) + + def test_decorator(self): + """Call the related action on the model + + The function is:: + + The ``related_action`` configuration is:: + + { + "func_name": "testing_related__url", + "kwargs": {"url": "https://en.wikipedia.org/wiki/{subject}"} + } + """ + job_ = self.record.with_delay().testing_related_action__store("Discworld") + expected = { + "type": "ir.actions.act_url", + "target": "new", + "url": "https://en.wikipedia.org/wiki/Discworld", + } + self.assertEqual(job_.related_action(), expected) diff --git a/test_queue_job/tests/test_requeue_dead_job.py b/test_queue_job/tests/test_requeue_dead_job.py new file mode 100644 index 0000000000..d41730dc64 --- /dev/null +++ b/test_queue_job/tests/test_requeue_dead_job.py @@ -0,0 +1,101 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# ruff: noqa: DTZ005 +from contextlib import closing +from datetime import datetime, timedelta + +from odoo.tests import tagged + +from odoo.addons.queue_job.job import Job +from odoo.addons.queue_job.jobrunner.runner import Database + +from .common import JobCommonCase + + +@tagged("post_install", "-at_install") +class TestRequeueDeadJob(JobCommonCase): + def get_locks(self, uuid, cr=None): + """ + Retrieve lock rows + """ + if cr is None: + cr = self.env.cr + + cr.execute( + """ + SELECT + queue_job_id + FROM + queue_job_lock + WHERE + queue_job_id IN ( + SELECT + id + FROM + queue_job + WHERE + uuid = %s + ) + FOR NO KEY UPDATE SKIP LOCKED + """, + [uuid], + ) + + return cr.fetchall() + + def test_add_lock_record(self): + queue_job = self._get_demo_job("test_started_job") + self.assertEqual(len(queue_job), 1) + job_obj = Job.load(self.env, queue_job.uuid) + + job_obj.set_started() + self.assertEqual(job_obj.state, "started") + + locks = self.get_locks(job_obj.uuid) + + self.assertEqual(1, len(locks)) + + def test_lock(self): + queue_job = self._get_demo_job("test_started_job") + job_obj = Job.load(self.env, queue_job.uuid) + + job_obj.set_started() + job_obj.lock() + + with closing(self.env.registry.cursor()) as new_cr: + locks = self.get_locks(job_obj.uuid, new_cr) + + # Row should be locked + self.assertEqual(0, len(locks)) + + def test_requeue_dead_jobs(self): + queue_job = self._get_demo_job("test_enqueued_job") + job_obj = Job.load(self.env, queue_job.uuid) + + job_obj.set_enqueued() + job_obj.set_started() + job_obj.date_enqueued = datetime.now() - timedelta(minutes=1) + job_obj.store() + + # requeue dead jobs using current cursor + query = Database(self.env.cr.dbname)._query_requeue_dead_jobs() + self.env.cr.execute(query) + + uuids_requeued = self.env.cr.fetchall() + self.assertTrue(queue_job.uuid in j[0] for j in uuids_requeued) + + def test_requeue_orphaned_jobs(self): + queue_job = self._get_demo_job("test_enqueued_job") + job_obj = Job.load(self.env, queue_job.uuid) + + # Only enqueued job, don't set it to started to simulate the scenario + # that system shutdown before job is starting + job_obj.set_enqueued() + job_obj.date_enqueued = datetime.now() - timedelta(minutes=1) + job_obj.store() + + # job is now picked up by the requeue query (which includes orphaned jobs) + query = Database(self.env.cr.dbname)._query_requeue_dead_jobs() + self.env.cr.execute(query) + uuids_requeued = self.env.cr.fetchall() + self.assertTrue(queue_job.uuid in j[0] for j in uuids_requeued)