newtratip
4 years ago
7 changed files with 56 additions and 19 deletions
-
15partner_contact_age_range/README.rst
-
4partner_contact_age_range/__manifest__.py
-
1partner_contact_age_range/readme/CONTRIBUTORS.rst
-
11partner_contact_age_range/static/description/index.html
-
37partner_contact_age_range/tests/test_res_partner_age_range.py
-
1setup/partner_contact_age_range/odoo/addons/partner_contact_age_range
-
6setup/partner_contact_age_range/setup.py
@ -1 +1,2 @@ |
|||
* Druidoo (<https://www.druidoo.io>) |
|||
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th> |
@ -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} |
|||
) |
|||
with self.assertRaises(ValidationError): |
|||
self.env["res.partner.age.range"].create( |
|||
{"name": "Toddler", "age_from": 1, "age_to": 4} |
|||
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.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) |
@ -0,0 +1 @@ |
|||
../../../../partner_contact_age_range |
@ -0,0 +1,6 @@ |
|||
import setuptools |
|||
|
|||
setuptools.setup( |
|||
setup_requires=['setuptools-odoo'], |
|||
odoo_addon=True, |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue