-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by carmenbianca
- Loading branch information
Showing
7 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-FileCopyrightText: 2023 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# This is an impossible scenario. It causes an endless loop bug that I'm not | ||
# able to debug exactly, but it's easier to just get rid of this scenario. | ||
sql = """ | ||
UPDATE res_partner | ||
SET parent_eater_id = null | ||
WHERE eater = 'worker_eater' | ||
""" | ||
openupgrade.logged_query(env.cr, sql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from odoo.exceptions import ValidationError | ||
from odoo.tests.common import SavepointCase | ||
|
||
|
||
class TestPartner(SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.worker_1 = cls.env["res.partner"].create( | ||
{ | ||
"name": "Worker 1", | ||
"eater": "worker_eater", | ||
} | ||
) | ||
cls.worker_2 = cls.env["res.partner"].create( | ||
{ | ||
"name": "Worker 2", | ||
"eater": "worker_eater", | ||
} | ||
) | ||
cls.eater_1 = cls.env["res.partner"].create( | ||
{ | ||
"name": "Eater 1", | ||
"eater": "eater", | ||
} | ||
) | ||
cls.eater_2 = cls.env["res.partner"].create( | ||
{ | ||
"name": "Eater 2", | ||
"eater": "eater", | ||
} | ||
) | ||
|
||
def test_eater_not_parent_of_worker_eater(self): | ||
with self.assertRaises(ValidationError): | ||
self.worker_1.parent_eater_id = self.eater_1 | ||
|
||
def test_worker_eater_not_child_of_eater(self): | ||
with self.assertRaises(ValidationError): | ||
self.eater_1.child_eater_ids = self.worker_1 | ||
|
||
def test_eater_not_parent_of_eater(self): | ||
with self.assertRaises(ValidationError): | ||
self.eater_1.parent_eater_id = self.eater_2 | ||
|
||
def test_worker_eater_no_parent(self): | ||
with self.assertRaises(ValidationError): | ||
self.worker_2.parent_eater_id = self.worker_1 | ||
|
||
def test_no_parent_of_self(self): | ||
with self.assertRaises(ValidationError): | ||
self.worker_2.parent_eater_id = self.worker_2 | ||
|
||
def test_worker_eater_parent_of_eater(self): | ||
self.eater_1.parent_eater_id = self.worker_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters