Browse Source
[FIX] base_optional_quick_create clears _api field of name_create method, unsetting the flag clears the patch
pull/14/head
[FIX] base_optional_quick_create clears _api field of name_create method, unsetting the flag clears the patch
pull/14/head
Simone Rubino
7 years ago
committed by
Pedro M. Baeza
5 changed files with 63 additions and 30 deletions
-
6base_optional_quick_create/__manifest__.py
-
23base_optional_quick_create/i18n/it.po
-
29base_optional_quick_create/models/ir_model.py
-
4base_optional_quick_create/tests/__init__.py
-
29base_optional_quick_create/tests/test_quick_create.py
@ -0,0 +1,4 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from . import test_quick_create |
@ -0,0 +1,29 @@ |
|||||
|
# -*- 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) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue