From 0c8816cc2b0d9c514b3c9d7df74cd58352e5da49 Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Fri, 9 Jul 2021 17:54:16 +0000 Subject: [PATCH] [FIX] lunch: access rights error on ir.cron for lunch manager Small fixup of recent commit https://github.com/odoo/odoo/commit/5b8eff9d771a9071327473d2185624f69e1057c1. closes odoo/odoo#73587 X-original-commit: d98a005c88b932a459b634cf811fb320cbea1357 Signed-off-by: Julien Castiaux Signed-off-by: Alex Tuyls --- addons/lunch/models/lunch_alert.py | 4 ++-- addons/lunch/models/lunch_supplier.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/lunch/models/lunch_alert.py b/addons/lunch/models/lunch_alert.py index 1bb21f95b56..662b3cf95d6 100644 --- a/addons/lunch/models/lunch_alert.py +++ b/addons/lunch/models/lunch_alert.py @@ -101,7 +101,8 @@ class LunchAlert(models.Model): sendat_tz = pytz.timezone(alert.tz).localize(datetime.combine( fields.Date.context_today(alert, fields.Datetime.now()), float_to_time(alert.notification_time, alert.notification_moment))) - lc = alert.cron_id.lastcall + cron = alert.cron_id.sudo() + lc = cron.lastcall if (( lc and sendat_tz.date() <= fields.Datetime.context_timestamp(alert, lc).date() ) or ( @@ -110,7 +111,6 @@ class LunchAlert(models.Model): sendat_tz += timedelta(days=1) sendat_utc = sendat_tz.astimezone(pytz.UTC).replace(tzinfo=None) - cron = alert.cron_id.sudo() cron.name = f"Lunch: alert chat notification ({alert.name})" cron.active = cron_required cron.nextcall = sendat_utc diff --git a/addons/lunch/models/lunch_supplier.py b/addons/lunch/models/lunch_supplier.py index dbc1b6045ea..1e8586aee22 100644 --- a/addons/lunch/models/lunch_supplier.py +++ b/addons/lunch/models/lunch_supplier.py @@ -112,7 +112,8 @@ class LunchSupplier(models.Model): sendat_tz = pytz.timezone(supplier.tz).localize(datetime.combine( fields.Date.context_today(supplier), float_to_time(supplier.automatic_email_time, supplier.moment))) - lc = supplier.cron_id.lastcall + cron = supplier.cron_id.sudo() + lc = cron.lastcall if (( lc and sendat_tz.date() <= fields.Datetime.context_timestamp(supplier, lc).date() ) or ( @@ -121,7 +122,6 @@ class LunchSupplier(models.Model): sendat_tz += timedelta(days=1) sendat_utc = sendat_tz.astimezone(pytz.UTC).replace(tzinfo=None) - cron = supplier.cron_id.sudo() cron.active = supplier.active and supplier.send_by == 'mail' cron.name = f"Lunch: send automatic email to {supplier.name}" cron.nextcall = sendat_utc