Browse Source
Merge pull request #1193 from SimoRubi/10.0-fix-base_optional_quick_create
Merge pull request #1193 from SimoRubi/10.0-fix-base_optional_quick_create
[FIX] base_optional_quick_create clears _api field of name_create methodpull/766/merge
Moises Lopez - https://www.vauxoo.com/
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 30 deletions
-
6base_optional_quick_create/__manifest__.py
-
25base_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