You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3 KiB

  1. # Copyright 2018 Simone Rubino - Agile Business Group
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo.tests import common
  4. from odoo.exceptions import UserError
  5. from odoo.tests.common import TransactionCase
  6. @common.at_install(False)
  7. @common.post_install(True)
  8. class TestQuickCreate(TransactionCase):
  9. def setUp(self, *args, **kwargs):
  10. super(TestQuickCreate, self).setUp()
  11. model_model = self.env['ir.model']
  12. self.partner_model = model_model.search([
  13. ('model', '=', 'res.partner')])
  14. def test_quick_create(self):
  15. partner_id = self.env['res.partner'].name_create('TEST partner')
  16. self.assertEqual(bool(partner_id), True)
  17. # Setting the flag, patches the method
  18. self.partner_model.avoid_quick_create = True
  19. with self.assertRaises(UserError):
  20. self.env['res.partner'].name_create('TEST partner')
  21. # Unsetting the flag, unpatches the method
  22. self.partner_model.avoid_quick_create = False
  23. partner_id = self.env['res.partner'].name_create('TEST partner')
  24. self.assertEqual(bool(partner_id), True)
  25. def test_create_model(self):
  26. model_id = self.env['ir.model'].create({'name': 'Test',
  27. 'model': 'x_test_model'})
  28. self.assertEqual(bool(model_id), True)