From 42828e938235dae5a0c09cfc47c1a7cd859f05b4 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 16 Sep 2014 12:55:22 +0200 Subject: [PATCH] Fix permissions issue. --- cron_run_manually/ir_cron.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/cron_run_manually/ir_cron.py b/cron_run_manually/ir_cron.py index 7ebb894e2..3a00f3cc5 100644 --- a/cron_run_manually/ir_cron.py +++ b/cron_run_manually/ir_cron.py @@ -61,17 +61,8 @@ class Cron(models.Model): _logger.info('Job `%s` triggered from form', self.name) - # Prepare execution - method = getattr(self.env[self.model], self.function) - args = safe_eval('tuple(%s)' % (self.args or '')) - - # Hack the UID - old_uid = self.env.uid - self.env.uid = self.user_id - # Execute the cron job - try: - method(*args) - finally: - # Revert UID to original - self.env.uid = old_uid + method = getattr(self.sudo(self.user_id).env[self.model], + self.function) + args = safe_eval('tuple(%s)' % (self.args or '')) + method(*args)