Skip to content

Commit a50a8f6

Browse files
committed
[MIG] partner_phone_secondary: Migration to 18.0
1 parent 2c3f067 commit a50a8f6

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

partner_phone_secondary/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Secondary phone number on partners",
66
"summary": "Adds a secondary phone number on partners",
77
"license": "AGPL-3",
8-
"version": "14.0.1.0.0",
8+
"version": "18.0.1.0.0",
99
"author": "Iván Todorovich, Odoo Community Association (OCA)",
1010
"maintainers": ["ivantodorovich"],
1111
"category": "Customer Relationship Management",

partner_phone_secondary/models/res_partner.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class ResPartner(models.Model):
1111

1212
@api.onchange("phone2", "country_id", "company_id")
1313
def _onchange_phone2_validation(self):
14-
# Compatibility with phone_validation
15-
if hasattr(self, "phone_format"):
16-
if self.phone2:
17-
self.phone2 = self.phone_format(self.phone2)
14+
# This is done in onchange to keep consistent with phone_validation
15+
# phone and mobile validation
16+
if self.phone2:
17+
self.phone2 = (
18+
self._phone_format(fname="phone2", force_format="INTERNATIONAL")
19+
or self.phone2
20+
)
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
# Copyright 2020 - Iván Todorovich
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo.tests.common import Form, TransactionCase
4+
from odoo.tests import Form, TransactionCase, tagged
55

66

7+
@tagged("post_install", "-at_install")
78
class TestPartnerPhoneSecondary(TransactionCase):
89
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

Comments
 (0)