From 71e9ffb564470b288c51082c4f5831d761f51394 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 11 Jul 2014 17:37:02 +0200 Subject: [PATCH] [PEP8] cron_run_manually --- cron_run_manually/model/ir_cron.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cron_run_manually/model/ir_cron.py b/cron_run_manually/model/ir_cron.py index 9b35ab95e..22c7f0720 100644 --- a/cron_run_manually/model/ir_cron.py +++ b/cron_run_manually/model/ir_cron.py @@ -27,9 +27,10 @@ from openerp.tools import SUPERUSER_ID from openerp.tools.translate import _ from openerp.tools.safe_eval import safe_eval + class irCron(orm.Model): _inherit = 'ir.cron' - + def run_manually(self, cr, uid, ids, context=None): """ Run a job from the cron form view. @@ -51,7 +52,7 @@ class irCron(orm.Model): _('Error'), _('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 @@ -67,8 +68,8 @@ class irCron(orm.Model): model = self.pool.get(job['model']) method = getattr(model, job['function']) args = safe_eval('tuple(%s)' % (job['args'] or '')) - method(cr, job['user_id'], *args) - + method(cr, job['user_id'], *args) + except psycopg2.OperationalError, e: # User friendly error if the lock could not be claimed if e.pgcode == '55P03':