Harald Panten
5 years ago
committed by
newtratip
7 changed files with 69 additions and 93 deletions
-
23partner_contact_department/__manifest__.py
-
8partner_contact_department/migrations/12.0.1.0.0/post-migration.py
-
28partner_contact_department/models/res_partner.py
-
1partner_contact_department/readme/CONTRIBUTORS.rst
-
25partner_contact_department/tests/test_recursion.py
-
13partner_contact_department/views/res_partner_department_view.xml
-
28partner_contact_department/views/res_partner_view.xml
@ -1,8 +0,0 @@ |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openupgradelib import openupgrade |
|||
|
|||
|
|||
@openupgrade.migrate(use_env=True) |
|||
def migrate(env, version): |
|||
env['res.partner.department']._parent_store_compute() |
@ -1,29 +1,26 @@ |
|||
# © 2016 Tecnativa - Vicent Cubells |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). |
|||
from odoo.exceptions import UserError |
|||
from odoo.tests import common |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class TestRecursion(common.SavepointCase): |
|||
|
|||
@classmethod |
|||
def setUpClass(cls): |
|||
super(TestRecursion, cls).setUpClass() |
|||
cls.department_obj = cls.env['res.partner.department'] |
|||
cls.department_obj = cls.env["res.partner.department"] |
|||
|
|||
# Instances |
|||
cls.dpt1 = cls.department_obj.create({'name': 'Dpt. 1'}) |
|||
cls.dpt2 = cls.department_obj.create({ |
|||
'name': 'Dep. 2', |
|||
'parent_id': cls.dpt1.id |
|||
}) |
|||
cls.dpt1 = cls.department_obj.create({"name": "Dpt. 1"}) |
|||
cls.dpt2 = cls.department_obj.create( |
|||
{"name": "Dep. 2", "parent_id": cls.dpt1.id} |
|||
) |
|||
|
|||
def test_recursion(self): |
|||
""" Testing recursion """ |
|||
self.dpt3 = self.department_obj.create({ |
|||
'name': 'Dep. 3', |
|||
'parent_id': self.dpt2.id |
|||
}) |
|||
self.dpt3 = self.department_obj.create( |
|||
{"name": "Dep. 3", "parent_id": self.dpt2.id} |
|||
) |
|||
# Creating a parent's child department using dpt1. |
|||
with self.assertRaises(ValidationError): |
|||
self.dpt1.write(vals={'parent_id': self.dpt3.id}) |
|||
with self.assertRaises(UserError): |
|||
self.dpt1.write(vals={"parent_id": self.dpt3.id}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue