diff options
| author | Thibault Delavallée <tde@odoo.com> | 2021-03-19 13:24:26 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2021-03-19 16:36:23 +0000 |
| commit | 73d09268922a7d242af85e36a3d81ed25ab4ca33 (patch) | |
| tree | 9c95b632128970e7cf8baf7c50cd3a42ab7d2058 /addons/event | |
| parent | 1a66d9cb57dc17b697b7a56effa91de3a4b50bd7 (diff) | |
[FIX] event: allow event user to confirm registrations even with mail schedulers
Due to ACLs it is currently impossible for event users to confirm a draft
registration if schedulers are involved. Indeed it implies updating the
scheduler which is not do-able for them.
In this commit we sudo the update of schedulers, as this is a technical
object and access is granted through registrations.
Related to Task ID-2414658
COM PR odoo/odoo#68158
Diffstat (limited to 'addons/event')
| -rw-r--r-- | addons/event/models/event_registration.py | 2 | ||||
| -rw-r--r-- | addons/event/tests/test_event_mail_schedule.py | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/addons/event/models/event_registration.py b/addons/event/models/event_registration.py index 58960460622..5b14153be03 100644 --- a/addons/event/models/event_registration.py +++ b/addons/event/models/event_registration.py @@ -160,7 +160,7 @@ class EventRegistration(models.Model): if vals.get('state') == 'open': # auto-trigger after_sub (on subscribe) mail schedulers, if needed onsubscribe_schedulers = self.mapped('event_id.event_mail_ids').filtered(lambda s: s.interval_type == 'after_sub') - onsubscribe_schedulers.execute() + onsubscribe_schedulers.sudo().execute() return ret diff --git a/addons/event/tests/test_event_mail_schedule.py b/addons/event/tests/test_event_mail_schedule.py index c7c61ee56c1..7ec60492b24 100644 --- a/addons/event/tests/test_event_mail_schedule.py +++ b/addons/event/tests/test_event_mail_schedule.py @@ -205,8 +205,7 @@ class TestMailSchedule(TestEventCommon, MockEmail): # NOTE: currently all schedulers are based on date_open which equals create_date # meaning several communications may be sent in the time time with freeze_time(now_start + relativedelta(hours=1)), self.mock_mail_gateway(): - # FIXME: sudo should not be necessary - reg3.sudo().action_confirm() + reg3.action_confirm() # verify that subscription scheduler was auto-executed after new registration confirmed self.assertEqual(len(after_sub_scheduler.mail_registration_ids), 3, 'event: should have 3 scheduled communication (1 / registration)') |
