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.

29 lines
1.1 KiB

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