Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] phone_validation: Support french mobile numbers starting with 7 #165160

Draft
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

nd-dew
Copy link
Contributor

@nd-dew nd-dew commented May 11, 2024

[FIX] phone_validation: Support french mobile numbers starting with 7

Mobile numbers in France start with 06 or 07 (ref1, ref2)
Currently used phonenumbers library (8.12.1) doesn't support numbers starting with 07,
neither the (currently) newest version of the phonenumbers library (8.13.36)

This commit modifies the new version of the phonenumbers metadata for French
mobile numbers adding support for mobile numbers starting with 7.

[Reproduce]

  • Install phone_validation,contacts
  • Set company country to France
  • Add contact with correct French NATIONAL number starting with 07
  • BUG: +33 is not added in front of the number

(ref.1)
https://en.wikipedia.org/wiki/Telephone_numbers_in_France

(ref.2)
https://www.itu.int/oth/T020200004A/en

opw-3860059

@robodoo
Copy link
Contributor

robodoo commented May 11, 2024

@nd-dew nd-dew force-pushed the 15.0-opw-3860059-recognize_french_mobile_numbers-pian branch from ced1d72 to b68e8ce Compare May 11, 2024 11:58
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 11, 2024
@nd-dew nd-dew force-pushed the 15.0-opw-3860059-recognize_french_mobile_numbers-pian branch from b68e8ce to 937f7f9 Compare May 12, 2024 11:15
Mobile numbers in France start with 06 or 07 (ref1, ref2)
Currently used phonenumbers library (8.12.1) doesn't support numbers starting with 07,
neither the (currently) newest version of the phonenumbers library (8.13.36)

This commit modifies the new version of the phonenumbers metadata for French
mobile numbers adding support for mobile numbers starting with 7.

[Reproduce]
- Install phone_validation,contacts
- Set company country to France
- Add contact with correct French NATIONAL number starting with 07
- BUG: +33 is not added in front of the number

(ref.1)
https://en.wikipedia.org/wiki/Telephone_numbers_in_France

(ref.2)
https://www.itu.int/oth/T020200004A/en

opw-3860059
@nd-dew nd-dew force-pushed the 15.0-opw-3860059-recognize_french_mobile_numbers-pian branch from 937f7f9 to 7452390 Compare May 12, 2024 11:24
Copy link
Contributor

@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I compare the two regexes, I get this:

2024-05-13-095133_1920x660_scrot

(old on left, new on right)

So 7 as beginning was already accepted but only if it was followed by a figure from 3 to 9. This corresponds (a little wider) to https://www.itu.int/oth/T020200004A/en that says numbers from 730 to 789 are used for mobile numbers.

With this change to the files we also accepts numbers beginning by 700 to 729 as mobile numbers. In the linked document, the only valid phone numbers in this range seems to be "7000" to "7004" but they are 13 digits instead of 9 and used for "Mobile numbers for machine to machine" not normal mobile numbers:

2024-05-13-095847_679x42_scrot

So as far as I can tell the change to the current version seems to not be useful since "07 01 43 78 61" doesn't seem to be a valid french number, but maybe I'm missing something.

If it was a real issue that needs to be solved, looks good to me with comment taken into account.

PHONE_METADATA_FR = PhoneMetadata(id='FR', country_code=33, international_prefix='00',
general_desc=PhoneNumberDesc(national_number_pattern='[1-9]\\d{8}', possible_length=(9,)),
fixed_line=PhoneNumberDesc(national_number_pattern='(?:26[013-9]|59[1-35-9])\\d{6}|(?:[13]\\d|2[0-57-9]|4[1-9]|5[0-8])\\d{7}', example_number='123456789', possible_length=(9,)),
mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),
Copy link
Contributor

@nle-odoo nle-odoo May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the intent of the change of the original file:

-    mobile=PhoneNumberDesc(national_number_pattern='(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),
+    mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),

is to add numbers beginning by 70 to 72, it would be cleaner to do it like this:

Suggested change
mobile=PhoneNumberDesc(national_number_pattern='(?:[67](?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}', example_number='612345678', possible_length=(9,)),
mobile=PhoneNumberDesc(national_number_pattern='(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7\\d{2})\\d{6}', example_number='612345678', possible_length=(9,)),

@nd-dew
Copy link
Contributor Author

nd-dew commented May 13, 2024

thanks for having a look @nle-odoo

I'm going to contact the person raising this issue, to get the actual problematic number, cause now I see that this seem like forcing an exception that shouldn't exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants