test_uninstall.py 1008 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo.tests import tagged, TransactionCase
  4. @tagged('-at_install', 'post_install')
  5. class TestMailUninstall(TransactionCase):
  6. def test_unlink_model(self):
  7. model = self.env['ir.model'].create({
  8. 'name': 'Test Model',
  9. 'model': 'x_test_model',
  10. 'state': 'manual',
  11. 'is_mail_thread': True,
  12. })
  13. activity_type = self.env['mail.activity.type'].create({
  14. 'name': 'Test Activity Type',
  15. 'res_model': model.model,
  16. })
  17. record = self.env[model.model].create({})
  18. activity = self.env['mail.activity'].create({
  19. 'activity_type_id': activity_type.id,
  20. 'res_model_id': model.id,
  21. 'res_id': record.id,
  22. })
  23. model.unlink()
  24. self.assertFalse(model.exists())
  25. self.assertFalse(activity_type.exists())
  26. self.assertFalse(activity.exists())