-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from OCA/17.0
Syncing from upstream OCA/queue (17.0)
- Loading branch information
Showing
23 changed files
with
888 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
=============================== | ||
Scheduled Actions as Queue Jobs | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c790b0e3494e59c709d57d7dbb0864ac37ce3af23801499f352df7528d5fe072 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
: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/17.0/queue_job_cron | ||
:alt: OCA/queue | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/queue-17-0/queue-17-0-queue_job_cron | ||
: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=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the functionality of queue_job and allows to run an | ||
Odoo cron as a queue job. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
1. Just install it. | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to a scheduled action, a flag "Run as queue job" will allow you to | ||
run the action as a queue job. You will also allowed to select a channel | ||
of its execution. To configure dedicated channels please refers to | ||
queue_job help: | ||
https://github.com/OCA/queue/blob/12.0/queue_job/README.rst | ||
|
||
Channels can be used to manage sequential jobs and prevent concurrency | ||
accesses. To do that you just have to define a channel per cron limited | ||
to 1 at time. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/queue/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/queue/issues/new?body=module:%20queue_job_cron%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* ACSONE SA/NV | ||
|
||
Contributors | ||
------------ | ||
|
||
- Cédric Pigeon <[email protected]> | ||
- Nguyen Minh Chien <[email protected]> | ||
|
||
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 <https://github.com/OCA/queue/tree/17.0/queue_job_cron>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
{ | ||
"name": "Scheduled Actions as Queue Jobs", | ||
"version": "17.0.1.0.0", | ||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/queue", | ||
"license": "AGPL-3", | ||
"category": "Generic Modules", | ||
"depends": ["queue_job"], | ||
"data": ["data/data.xml", "views/ir_cron_view.xml"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record model="queue.job.channel" id="channel_root_ir_cron"> | ||
<field name="name">ir_cron</field> | ||
<field name="parent_id" ref="queue_job.channel_root" /> | ||
</record> | ||
<record model="queue.job.function" id="job_function_ir_cron_run_job_as_queue_job"> | ||
<field name="model_id" ref="base.model_ir_cron" /> | ||
<field name="method">_compute_run_as_queue_job</field> | ||
<field name="channel_id" ref="channel_root_ir_cron" /> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * queue_job_cron | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2019-07-12 14:43+0000\n" | ||
"Last-Translator: Maria Sparenberg <[email protected]>\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 3.7.1\n" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__channel_id | ||
msgid "Channel" | ||
msgstr "Kanal" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Run As Queue Job" | ||
msgstr "als Warteschlangen-Job ausführen" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model,name:queue_job_cron.model_ir_cron | ||
msgid "Scheduled Actions" | ||
msgstr "Eingeplante Aktionen" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,help:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Specify if this cron should be ran as a queue job" | ||
msgstr "" | ||
"Bitte spezifizieren, ob der Cron-Job als Warteschlangen-Job ausgeführt " | ||
"werden soll." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * queue_job_cron | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2023-09-03 13:40+0000\n" | ||
"Last-Translator: kikopeiro <[email protected]>\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: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__channel_id | ||
msgid "Channel" | ||
msgstr "Canal" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Run As Queue Job" | ||
msgstr "Ejecutar como trabajo en cola" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model,name:queue_job_cron.model_ir_cron | ||
msgid "Scheduled Actions" | ||
msgstr "Acciones planificadas" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,help:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Specify if this cron should be ran as a queue job" | ||
msgstr "" | ||
"Especifica si esta acción planificada deberá ser ejecutada como un trabajo " | ||
"en cola" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * queue_job_cron | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.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_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__channel_id | ||
msgid "Channel" | ||
msgstr "" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Run As Queue Job" | ||
msgstr "" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model,name:queue_job_cron.model_ir_cron | ||
msgid "Scheduled Actions" | ||
msgstr "" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,help:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Specify if this cron should be ran as a queue job" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * queue_job_cron | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2019-07-25 17:43+0000\n" | ||
"Last-Translator: 黎伟杰 <[email protected]>\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 3.7.1\n" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__channel_id | ||
msgid "Channel" | ||
msgstr "频道" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,field_description:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Run As Queue Job" | ||
msgstr "作为队列作业运行" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model,name:queue_job_cron.model_ir_cron | ||
msgid "Scheduled Actions" | ||
msgstr "安排的动作" | ||
|
||
#. module: queue_job_cron | ||
#: model:ir.model.fields,help:queue_job_cron.field_ir_cron__run_as_queue_job | ||
msgid "Specify if this cron should be ran as a queue job" | ||
msgstr "指定此cron是否应作为队列作业运行" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import ir_cron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
import logging | ||
|
||
from odoo import api, fields, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class IrCron(models.Model): | ||
_inherit = "ir.cron" | ||
|
||
run_as_queue_job = fields.Boolean( | ||
help="Specify if this cron should be ran as a queue job" | ||
) | ||
channel_id = fields.Many2one( | ||
comodel_name="queue.job.channel", | ||
compute="_compute_run_as_queue_job", | ||
readonly=False, | ||
string="Channel", | ||
) | ||
|
||
@api.depends("run_as_queue_job") | ||
def _compute_run_as_queue_job(self): | ||
for cron in self: | ||
if cron.run_as_queue_job and not cron.channel_id: | ||
cron.channel_id = self.env.ref("queue_job_cron.channel_root_ir_cron").id | ||
else: | ||
cron.channel_id = False | ||
|
||
def _run_job_as_queue_job(self, server_action): | ||
return server_action.run() | ||
|
||
def method_direct_trigger(self): | ||
for cron in self: | ||
if not cron.run_as_queue_job: | ||
super(IrCron, cron).method_direct_trigger() | ||
else: | ||
_cron = cron.with_user(cron.user_id).with_context( | ||
lastcall=cron.lastcall | ||
) | ||
_cron.with_delay( | ||
priority=_cron.priority, | ||
description=_cron.name, | ||
channel=_cron.channel_id.complete_name, | ||
)._run_job_as_queue_job(server_action=_cron.ir_actions_server_id) | ||
return True | ||
|
||
def _callback(self, cron_name, server_action_id, job_id): | ||
cron = self.env["ir.cron"].sudo().browse(job_id) | ||
if cron.run_as_queue_job: | ||
server_action = self.env["ir.actions.server"].browse(server_action_id) | ||
return self.with_delay( | ||
priority=cron.priority, | ||
description=cron.name, | ||
channel=cron.channel_id.complete_name, | ||
)._run_job_as_queue_job(server_action=server_action) | ||
else: | ||
return super()._callback( | ||
cron_name=cron_name, server_action_id=server_action_id, job_id=job_id | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
To configure this module, you need to: | ||
|
||
#. Nothing special to do. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Cédric Pigeon \<<[email protected]>\> | ||
- Nguyen Minh Chien \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This module extends the functionality of queue_job and allows to run an | ||
Odoo cron as a queue job. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
To install this module, you need to: | ||
|
||
1. Just install it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
To use this module, you need to: | ||
|
||
#\. Go to a scheduled action, a flag "Run as queue job" will allow you | ||
to run the action as a queue job. You will also allowed to select a | ||
channel of its execution. To configure dedicated channels please refers | ||
to queue_job help: | ||
<https://github.com/OCA/queue/blob/12.0/queue_job/README.rst> | ||
|
||
Channels can be used to manage sequential jobs and prevent concurrency | ||
accesses. To do that you just have to define a channel per cron limited | ||
to 1 at time. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.