openwisp / openwisp-notifications

Notifications module of OpenWISP
https://openwisp.io/docs/dev/notifications/
GNU General Public License v3.0
40 stars 41 forks source link

[bug] Organization.DoesNotExist openwisp_notifications.tasks.ns_organization_created #238

Closed nemesifier closed 2 years ago

nemesifier commented 2 years ago

When creating a new org in a prod system this exception pops up.

I think it's because we have to use transaction.on_commit on the handler as we use for the other receivers, otherwise the celery task is spawned before the transaction is saved to the DB and the organization does not exist yet.

Keep in mind that when doing this, some tests may fail because transactions are not enabled in TestCase, for that reason the on_commit may not be triggered, for that reason some tests run in TransactionTestCase