Stefan Rijnhart
9 years ago
13 changed files with 0 additions and 469 deletions
-
20cron_run_manually/__init__.py
-
37cron_run_manually/__openerp__.py
-
33cron_run_manually/i18n/cron_run_manually.pot
-
40cron_run_manually/i18n/en.po
-
40cron_run_manually/i18n/es.po
-
41cron_run_manually/i18n/fr.po
-
40cron_run_manually/i18n/nl.po
-
41cron_run_manually/i18n/pt_BR.po
-
41cron_run_manually/i18n/sl.po
-
78cron_run_manually/ir_cron.py
-
BINcron_run_manually/static/description/icon.png
-
23cron_run_manually/tests/correct_uid.yml
-
35cron_run_manually/view/ir_cron.xml
@ -1,20 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# Code snippets from openobject-server copyright (C) 2004-2013 OpenERP S.A. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
|
|||
from . import ir_cron |
@ -1,37 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# Code snippets from openobject-server copyright (C) 2004-2013 OpenERP S.A. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
|
|||
{ |
|||
'name': 'Call cron jobs from their form view', |
|||
'version': '8.0.1.0.0', |
|||
'author': "Therp BV (OpenERP S.A.),Odoo Community Association (OCA)", |
|||
'license': 'AGPL-3', |
|||
'category': 'Tools', |
|||
'description': """ |
|||
This module adds a button to the cron scheduled task form in OpenERP |
|||
that allows the administrator to run the job immediately, independently |
|||
of the scheduler. |
|||
""", |
|||
'depends': ['base', 'mail'], |
|||
'data': ['view/ir_cron.xml'], |
|||
"test": [ |
|||
"tests/correct_uid.yml", |
|||
], |
|||
'installable': False, |
|||
} |
@ -1,33 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0rc1\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2014-09-16 09:47+0000\n" |
|||
"PO-Revision-Date: 2014-09-16 09:47+0000\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: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:57 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "" |
@ -1,40 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-18 13:54+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" |
|||
"Language-Team: English (http://www.transifex.com/oca/OCA-server-tools-8-0/language/en/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: en\n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Another process/thread is already busy executing this job" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "Run Now" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Run now" |
@ -1,40 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-18 13:54+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" |
|||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-server-tools-8-0/language/es/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: es\n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Hay otro proceso o hilo ejecutando este trabajo en este momento" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "Solo el administrador puede ejecutar manualmente trabajos cron inactivos" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Ejecutar ahora" |
@ -1,41 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
# Pierre Verkest <pverkest@anybox.fr>, 2015 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-24 21:08+0000\n" |
|||
"Last-Translator: Pierre Verkest <pverkest@anybox.fr>\n" |
|||
"Language-Team: French (http://www.transifex.com/oca/OCA-server-tools-8-0/language/fr/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: fr\n" |
|||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Cette tâche est déjà en cours par un autre processus" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "Seul l'administrateur est autorisé à exécuter manuellement des tâches planifiées inactives " |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "Démarrer" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Démarrer" |
@ -1,40 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-18 13:54+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" |
|||
"Language-Team: Dutch (http://www.transifex.com/oca/OCA-server-tools-8-0/language/nl/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: nl\n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Deze job wordt op dit moment al uitgevoerd door een ander proces" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Nu uitvoeren" |
@ -1,41 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
# Armando Vulcano Junior <vulcano@uol.com.br>, 2015 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-18 21:19+0000\n" |
|||
"Last-Translator: Armando Vulcano Junior <vulcano@uol.com.br>\n" |
|||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-server-tools-8-0/language/pt_BR/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: pt_BR\n" |
|||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Um outro processo já está ocupado executando este trabalho" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "Apenas o usuário administrador está autorizado a executar cron jobs inativos manualmente" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "Executar Agora" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Executar agora" |
@ -1,41 +0,0 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * cron_run_manually |
|||
# |
|||
# Translators: |
|||
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: server-tools (8.0)\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2015-09-29 11:14+0000\n" |
|||
"PO-Revision-Date: 2015-09-26 07:44+0000\n" |
|||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n" |
|||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-server-tools-8-0/language/sl/)\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Language: sl\n" |
|||
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:56 |
|||
#, python-format |
|||
msgid "Another process/thread is already busy executing this job" |
|||
msgstr "Pri izvajanju te naloge je zaposlen že drug proces" |
|||
|
|||
#. module: cron_run_manually |
|||
#: code:addons/cron_run_manually/ir_cron.py:38 |
|||
#, python-format |
|||
msgid "Only the admin user is allowed to execute inactive cron jobs manually" |
|||
msgstr "Le administrator lahko ročno izvaja 'cron jobs'" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view_tree_inherited |
|||
msgid "Run Now" |
|||
msgstr "Zaženi zdaj" |
|||
|
|||
#. module: cron_run_manually |
|||
#: view:ir.cron:cron_run_manually.ir_cron_view |
|||
msgid "Run now" |
|||
msgstr "Zaženi zdaj" |
@ -1,78 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Therp BV (<http://therp.nl>) |
|||
# Code snippets from openobject-server copyright (C) 2004-2013 OpenERP S.A. |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
|
|||
import logging |
|||
from openerp import _, api, exceptions, models, SUPERUSER_ID |
|||
from openerp.tools.safe_eval import safe_eval |
|||
from psycopg2 import OperationalError |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class Cron(models.Model): |
|||
_name = _inherit = "ir.cron" |
|||
|
|||
@api.one |
|||
def run_manually(self): |
|||
"""Run a job from the cron form view.""" |
|||
|
|||
if self.env.uid != SUPERUSER_ID and (not self.active or |
|||
not self.numbercall): |
|||
raise exceptions.AccessError( |
|||
_('Only the admin user is allowed to ' |
|||
'execute inactive cron jobs manually')) |
|||
|
|||
try: |
|||
# Try to grab an exclusive lock on the job row |
|||
# until the end of the transaction |
|||
self.env.cr.execute( |
|||
"""SELECT * |
|||
FROM ir_cron |
|||
WHERE id=%s |
|||
FOR UPDATE NOWAIT""", |
|||
(self.id,), |
|||
log_exceptions=False) |
|||
|
|||
except OperationalError as e: |
|||
# User friendly error if the lock could not be claimed |
|||
if getattr(e, "pgcode", None) == '55P03': |
|||
raise exceptions.Warning( |
|||
_('Another process/thread is already busy ' |
|||
'executing this job')) |
|||
|
|||
raise |
|||
|
|||
_logger.info('Job `%s` triggered from form', self.name) |
|||
|
|||
# Do not propagate active_test to the method to execute |
|||
ctx = dict(self.env.context) |
|||
ctx.pop('active_test', None) |
|||
|
|||
# Execute the cron job |
|||
method = getattr( |
|||
self.with_context(ctx).sudo(self.user_id).env[self.model], |
|||
self.function) |
|||
args = safe_eval('tuple(%s)' % (self.args or '')) |
|||
return method(*args) |
|||
|
|||
@api.model |
|||
def _current_uid(self): |
|||
"""This function returns the current UID, for testing purposes.""" |
|||
|
|||
return self.env.uid |
Before Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -1,23 +0,0 @@ |
|||
- I create a user that will run the job. |
|||
- !record {model: res.users, id: worker_user, view: False}: |
|||
company_id: base.main_company |
|||
name: worker |
|||
login: worker |
|||
password: worker |
|||
email: worker@example.com |
|||
|
|||
- Create a cron job to check the UID |
|||
- !record {model: ir.cron, id: check_uid_job}: |
|||
name: Check UID |
|||
active: True |
|||
user_id: worker_user |
|||
interval_number: 1 |
|||
interval_type: days |
|||
numbercall: -1 |
|||
doall: False |
|||
model: ir.cron |
|||
function: _current_uid |
|||
|
|||
- I execute the cron job manually to check its running UID |
|||
- !python {model: ir.cron, id: check_uid_job}: | |
|||
assert self.run_manually()[0] == self.user_id.id, "Wrong UID in cron job" |
@ -1,35 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="ir_cron_view" model="ir.ui.view"> |
|||
<field name="model">ir.cron</field> |
|||
<field name="inherit_id" ref="base.ir_cron_view" /> |
|||
<field name="arch" type="xml"> |
|||
<field name="args" position="after"> |
|||
<button name="run_manually" |
|||
string="Run now" |
|||
type="object" |
|||
/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="ir_cron_view_tree_inherited" model="ir.ui.view"> |
|||
<field name="name">ir.cron.tree</field> |
|||
<field name="inherit_id" ref="base.ir_cron_view_tree"/> |
|||
<field name="model">ir.cron</field> |
|||
<field name="type">tree</field> |
|||
<field name="arch" type="xml"> |
|||
<field name="numbercall" position="after"> |
|||
<button icon="gtk-go-forward" |
|||
name="run_manually" |
|||
string="Run Now" |
|||
type="object"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue