|
1 | 1 | # Copyright 2020 - Iván Todorovich
|
2 | 2 | # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
3 | 3 |
|
4 |
| -from odoo.tests.common import Form, TransactionCase |
| 4 | +from odoo.tests import Form, TransactionCase, tagged |
5 | 5 |
|
6 | 6 |
|
| 7 | +@tagged("post_install", "-at_install") |
7 | 8 | class TestPartnerPhoneSecondary(TransactionCase):
|
8 | 9 | def test_01_phone_validation_compatibility(self):
|
9 |
| - # This is here only to get code coverage. |
10 |
| - with Form(self.env["res.partner"]) as form: |
11 |
| - form.name = "French Partner" |
12 |
| - form.country_id = self.env.ref("base.fr") |
13 |
| - form.phone = "766666666" |
14 |
| - form.phone2 = "766666666" |
15 |
| - # It's not the purpose of this module to test phone_validation, |
16 |
| - # nor how it formats phone numbers. Also it's not directly depended |
17 |
| - # by this module. We do know for sure, though, that the same number |
18 |
| - # is going to be formatted in the exact same way. |
19 |
| - self.assertEqual(form.phone, form.phone2) |
| 10 | + is_phone_validation_installed = self.env["ir.module.module"].search( |
| 11 | + [("name", "=", "phone_validation"), ("state", "=", "installed")] |
| 12 | + ) |
| 13 | + |
| 14 | + form = Form(self.env["res.partner"]) |
| 15 | + form.country_id = self.env.ref("base.be") |
| 16 | + form.phone = "0456998877" |
| 17 | + form.phone2 = "0456998899" |
| 18 | + |
| 19 | + if is_phone_validation_installed: |
| 20 | + self.assertEqual(form.phone, "+32 456 99 88 77") |
| 21 | + self.assertEqual(form.phone2, "+32 456 99 88 99") |
| 22 | + else: |
| 23 | + self.assertEqual(form.phone, "0456998877") |
| 24 | + self.assertEqual(form.phone2, "0456998899") |
0 commit comments