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
29 lines
1.1 KiB
# -*- coding: utf-8 -*-
|
|
# Copyright 2018 Simone Rubino - Agile Business Group
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
from odoo.exceptions import UserError
|
|
from odoo.tests.common import TransactionCase
|
|
|
|
|
|
class TestQuickCreate(TransactionCase):
|
|
|
|
def setUp(self, *args, **kwargs):
|
|
super(TestQuickCreate, self).setUp()
|
|
model_model = self.env['ir.model']
|
|
self.partner_model = model_model.search([
|
|
('model', '=', 'res.partner')])
|
|
|
|
def test_quick_create(self):
|
|
partner_id = self.env['res.partner'].name_create('TEST partner')
|
|
self.assertEqual(bool(partner_id), True)
|
|
|
|
# Setting the flag, patches the method
|
|
self.partner_model.avoid_quick_create = True
|
|
with self.assertRaises(UserError):
|
|
self.env['res.partner'].name_create('TEST partner')
|
|
|
|
# Unsetting the flag, unpatches the method
|
|
self.partner_model.avoid_quick_create = False
|
|
partner_id = self.env['res.partner'].name_create('TEST partner')
|
|
self.assertEqual(bool(partner_id), True)
|