-
-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] partner_contact_age_range: Migration to 14.0
- Loading branch information
Showing
7 changed files
with
56 additions
and
19 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
* Druidoo (<https://www.druidoo.io>) | ||
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th> |
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
37 changes: 32 additions & 5 deletions
37
partner_contact_age_range/tests/test_res_partner_age_range.py
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 |
---|---|---|
@@ -1,16 +1,43 @@ | ||
# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>) | ||
# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from datetime import datetime | ||
|
||
from dateutil.relativedelta import relativedelta | ||
|
||
from odoo.exceptions import ValidationError | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestRespartnerAgeRange(TransactionCase): | ||
def test_overlap(self): | ||
self.env["res.partner.age.range"].create( | ||
def setUp(self): | ||
super().setUp() | ||
self.range_model = self.env["res.partner.age.range"] | ||
self.partner_model = self.env["res.partner"] | ||
self.baby_range = self.range_model.create( | ||
{"name": "baby", "age_from": 0, "age_to": 2} | ||
) | ||
self.partner = self.partner_model.create( | ||
{ | ||
"name": "Test", | ||
"birthdate_date": datetime.today() - relativedelta(years=1, days=10), | ||
} | ||
) | ||
|
||
def test_age_from(self): | ||
age_from = self.range_model._default_age_from() | ||
toddler_range = self.range_model.create( | ||
{"name": "Toddler", "age_from": age_from, "age_to": 4} | ||
) | ||
self.assertEqual(toddler_range.age_from, self.baby_range.age_to + 1) | ||
|
||
def test_validate_range(self): | ||
with self.assertRaises(ValidationError): | ||
self.env["res.partner.age.range"].create( | ||
{"name": "Toddler", "age_from": 1, "age_to": 4} | ||
) | ||
self.range_model.create({"name": "Child", "age_from": 1, "age_to": 12}) | ||
with self.assertRaises(ValidationError): | ||
self.range_model.create({"name": "Teenager", "age_from": 16, "age_to": 15}) | ||
|
||
def test_cron_update_age_range_id(self): | ||
self.partner_model._cron_update_age_range_id() | ||
self.assertEqual(self.partner.age_range_id, self.baby_range) |
1 change: 1 addition & 0 deletions
1
setup/partner_contact_age_range/odoo/addons/partner_contact_age_range
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 @@ | ||
../../../../partner_contact_age_range |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |