libracore / WooCommerceConnector

Integration App for ERPNext to connect to WooCommerce
Other
81 stars 136 forks source link

TypeError: 'InvalidPhoneNumberError' object is not subscriptable #75

Open solaress opened 1 year ago

solaress commented 1 year ago

I believe this plugin is amazing work, i have successfully imported products and customers but having error on importing orders from woo to erpnext. As i understood some issue with prone numbers, some customers use + or "( )" or space, i believe it causes the error, can you please have a look ? Thank you

Traceback (most recent call last): File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 153, in create_customer_contact }).insert() File "apps/frappe/frappe/model/document.py", line 260, in insert self._validate() File "apps/frappe/frappe/model/document.py", line 529, in _validate self._validate_data_fields() File "apps/frappe/frappe/model/base_document.py", line 859, in _validate_data_fields frappe.utils.validate_phone_number(data, throw=True) File "apps/frappe/frappe/utils/init.py", line 129, in validate_phone_number frappe.throw( File "apps/frappe/frappe/init.py", line 525, in throw msgprint( File "apps/frappe/frappe/init.py", line 493, in msgprint _raise_exception() File "apps/frappe/frappe/init.py", line 442, in _raise_exception raise raise_exception(msg) frappe.exceptions.InvalidPhoneNumberError: '+19567844735 is not a valid Phone Number

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 60, in create_customer create_customer_contact(customer, woocommerce_customer) File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 156, in create_customer_contact make_woocommerce_log(title=e, status="Error", method="create_customer_contact", message=frappe.get_traceback(), File "apps/woocommerceconnector/woocommerceconnector/utils.py", line 54, in make_woocommerce_log log.title = title[0:140] TypeError: 'InvalidPhoneNumberError' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "apps/woocommerceconnector/woocommerceconnector/api.py", line 51, in sync_woocommerce_resources sync_customers() File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 10, in sync_customers sync_woocommerce_customers(woocommerce_customer_list) File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 19, in sync_woocommerce_customers create_customer(woocommerce_customer, woocommerce_customer_list) File "apps/woocommerceconnector/woocommerceconnector/sync_customers.py", line 71, in create_customer make_woocommerce_log(title=e, status="Error", method="create_customer", message=frappe.get_traceback(), File "apps/woocommerceconnector/woocommerceconnector/utils.py", line 54, in make_woocommerce_log log.title = title[0:140] TypeError: 'TypeError' object is not subscriptable

solaress commented 1 year ago

No help here ? Plugin doesnt work where the phone number has characters, and if we sync any amazon or ebay data, their phone numbers always contains + at the beginning country code, and "ext" text and xxxx 4 digits in the phone field.

similar error has been raised and solved on shopify , (https://github.com/frappe/ecommerce_integrations/pull/100/files) can somebody please help me bypass phone verification on customer creation ?

sptechcue commented 1 year ago

How do you have woocommerce data entry configured in woocommerce.

solaress commented 1 year ago

How do you have woocommerce data entry configured in woocommerce.

Data comes to woocommerce from amazon, via wp-lister for amazon plugin to woocommerce( there are other marketplaces to woocommerce plugins as well) , then to erpnext, at least that was the plan, however, as i desperatly need, USA or CA or and soon EU phone numbers are masked by the amazon, so they will always have "ext" text and 4 more digits, so everytime plugin sees a phone number field it throws not a valid phone number. please show us a way not to import this field, or make it as text data readable. thank you

sptechcue commented 1 year ago

phone number field it throws not a valid phone number

I just recreated a purchase in a test system I have using special characters in the phone as you can see, the system imports the data correctly.

3 1 2 4 5
solaress commented 1 year ago

this one seems correct but in my case and on every amazon / ebay phone field the word “ext” or “external” string comes too… can you please try like that ? i know it doesnt make sense to input letters into phone number area, but thats the case and since amazon / ebay does that, it means it will be common use. ( wordpress lets you put text into phone area )

in this plugin end maybe a quick fix can be skip confirming the validity of phone, they fixed like that on shopify example. another approach could send to erp only the numbers and omit the text part.

thank you for your effort

sptechcue commented 1 year ago

amazon / ebay phone field the word “ext” or “external” string

Can you send me a screenshot of how you receive the data in woocommerce from Amazon. It comes to you as an order.

image

Edit in the following file: the word True to False

File "apps/frappe/model/base_document.py", line 749, in _validate_data_fields frappe.utils.validate_phone_number(data, throw=False)

6