Step to reproduce: - Install contacts - create a new contact and set "Côte d'Ivoire" as country - add a phone number like this one: (+225) 01 02 03 04 05 - try to send a sms to the number, it's says "(Invalid number)" instead of the number, so it's not possible to send the SMS The Ivory Coast has a new standard for the phone number since the 31 January 2021, the phone number can have a length of ten digits. And we use the library phonenumbers with the version 8.9.10 and 8.8.1 for the runbot and the SaaS server, but it's quite old (the 8.9.10 is released on Jul 12 2018). The library in version 8.12.29 resolve the issue, but using the recommended installation method, we would not have this version. opw-2726582 closes odoo/odoo#86742 X-original-commit: 2f718cd78feeafb82b2d11a58e1a518a69d52c5e Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: Bruno-brsy <brsy@odoo.com>
33 lines
1.9 KiB
Python
33 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
try:
|
|
import phonenumbers
|
|
except ImportError:
|
|
phonenumbers = None
|
|
|
|
from odoo.tests.common import BaseCase
|
|
from odoo.tools.parse_version import parse_version
|
|
from odoo.addons.phone_validation.lib import phonenumbers_patch
|
|
|
|
class TestPhonenumbersPatch(BaseCase):
|
|
def test_region_CI_monkey_patch(self):
|
|
"""Test if the patch is apply on the good version of the lib
|
|
And test some phonenumbers"""
|
|
if not phonenumbers:
|
|
self.skipTest('Cannot test without phonenumbers module installed.')
|
|
# MONKEY PATCHING phonemetadata of Ivory Coast if phonenumbers is too old
|
|
if parse_version('7.6.1') <= parse_version(phonenumbers.__version__) < parse_version('8.12.32'):
|
|
# check that _local_load_region is set to `odoo.addons.phone_validation.lib.phonenumbers_patch._local_load_region`
|
|
# check that you can load a new ivory coast phone number without error
|
|
parsed_phonenumber_1 = phonenumbers.parse("20 25/35-51 ", region="CI", keep_raw_input=True)
|
|
self.assertEqual(parsed_phonenumber_1.national_number, 20253551, "The national part of the phonenumber should be 22522586")
|
|
self.assertEqual(parsed_phonenumber_1.country_code, 225, "The country code of Ivory Coast is 225")
|
|
|
|
parsed_phonenumber_2 = phonenumbers.parse("+225 22 52 25 86 ", region="CI", keep_raw_input=True)
|
|
self.assertEqual(parsed_phonenumber_2.national_number, 22522586, "The national part of the phonenumber should be 22522586")
|
|
self.assertEqual(parsed_phonenumber_2.country_code, 225, "The country code of Ivory Coast is 225")
|
|
else:
|
|
self.assertFalse(hasattr(phonenumbers_patch, '_local_load_region'),
|
|
"The code should not be monkey patched with phonenumbers > 8.12.32.")
|