Woocommerce full 2 way integration

I have the same error trying to “get-app”

INFO:bench.app:installing woocommerceconnector
$ ./env/bin/pip install -q -U -e ./apps/woocommerceconnector
    ERROR: Command errored out with exit status 1:
     command: /opt/erpnext/erpnext/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/opt/erpnext/erpnext/apps/woocommerceconnector/setup.py'"'"'; __file__='"'"'/opt/erpnext/erpnext/apps/woocommerceconnector/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-doxlg29b
         cwd: /opt/erpnext/erpnext/apps/woocommerceconnector/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/opt/erpnext/erpnext/apps/woocommerceconnector/setup.py", line 27, in <module>
        install_requires=[str(ir.req) for ir in requirements],
      File "/opt/erpnext/erpnext/apps/woocommerceconnector/setup.py", line 27, in <listcomp>
        install_requires=[str(ir.req) for ir in requirements],
    AttributeError: 'ParsedRequirement' object has no attribute 'req'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
$ bench build --app woocommerceconnector
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/erpnext/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/opt/erpnext/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/erpnext/erpnext/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/erpnext/erpnext/apps/frappe/frappe/commands/utils.py", line 25, in build
    frappe.init('')
  File "/opt/erpnext/erpnext/apps/frappe/frappe/__init__.py", line 173, in init
    setup_module_map()
  File "/opt/erpnext/erpnext/apps/frappe/frappe/__init__.py", line 1015, in setup_module_map
    for module in get_module_list(app):
  File "/opt/erpnext/erpnext/apps/frappe/frappe/__init__.py", line 884, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
  File "/opt/erpnext/erpnext/apps/frappe/frappe/__init__.py", line 842, in get_module
    return importlib.import_module(modulename)
  File "/opt/erpnext/erpnext/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'woocommerceconnector'

Hi @zerodiscount,

sorry for the late response, but the “Asset Settings” issue is unrelated to WooCommerce…

The ‘req’ issue is a Python compatibility issue. I noted that the setup still had the old version code, this is now updated.

Thanks @lasalesi for the reply - better late than never… appreciate the contributions.

$ bench mariadb
> delete from `tabDocType` where `name` = "Asset Settings";

Is it ok to resolve the “Asset Settings” issue with above commands? Half knowledge is dangerous - and I dont know if above command will break other part of ERPNext . I did check - there is no category called Asset Settings in ERPNext - so is it something being called by your app?

@lasalesi - had another question related to functionality - will this app create a payment entry in ERPNext for orders that are paid in woocommerce (using woocommerce payment gateways)?

Asset Settings is a normal doctype:


this is a screenshot from a v12.1 instance…

When I checked on a v12.4 instance, this doctype is gone… So this must have been removed lately, and this causes your issue. But has nothing to do with the WooCommerce integration. From what I see, if you run v12.4 or later, it should be save to drop this table.

As far as I know, the connector does not sync the payment entries, but the sales invoices (in case of payment with the is_paid option).

@lasalesi - many thanks for the follow up. I was able to install the app and actually get sync to work partially / initially. Its sync’s IDs without issue and even synced a trial customer - which existed in erpnext - so it created a new one with a “-1”. Products in woocommerce were specified as a separate erpnext category. when I tried to get some regular erpnext product items to sync - i get the following error:

File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://shop.domain.com/wp-json/wc/v3/products/607?oauth_consumer_key=ck_MY-Key_9c&oauth_timestamp=1588799441&oauth_nonce=123abc_Nonce_def&oauth_signature_method=HMAC-SHA256&oauth_signature=dT_MySignature_%3D

By this I meant - I check marked for items - sync quantity with woocommerce and also the other checkmark to sync item with woocommerce…

You can only sync stock once the connection between the item in WooCommerce and ERPNext is established. This should be the case, as you have synced the IDs… Have you tried to troubleshoot the URL if this has an issue (e.g. using Postman)?

You mean existing item from Woocommerce can sync to new item in ERPnext but not other way around? Tried unchecking the sync quantity with woocommerce, keeping the checkmark for sync item with woocommerce. it does not work/

Also FYI - items from 1 WooCommerce Category sync to ERPNext. The other category items do not sync with ID sync…

There might be a configuration issue at hand. Feel free to PM me to troubleshoot.

@lasalesi

Trust you are doing very well

I got error message below while trying to sync sales order to ERPNext. Any

Traceback (most recent call last):
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/sync_products.py”, line 132, in sync_erpnext_items
sync_item_with_woocommerce(item, price_list, warehouse, woocommerce_item_list.get(item.get(‘woocommerce_product_id’)))
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/sync_products.py”, line 243, in sync_item_with_woocommerce
sync_item_image(erp_item)
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/sync_products.py”, line 270, in sync_item_image
post_request(“products/{0}”.format(item.woocommerce_product_id), image_info)
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/woocommerce_requests.py”, line 69, in post_request
r.raise_for_status()
File “/home/frappe/bench12/env/lib/python3.8/site-packages/requests/models.py”, line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://xlweb.one/okearin/wp-json/wc/v3/products/280?oauth_consumer_key=ck_*******************************&oauth_timestamp=1588866575&oauth_nonce=ce**************************&oauth_signature_method=HMAC-SHA256&oauth_signature=wVW5SIDtxRrB31SLc***************************

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/api.py”, line 41, in sync_woocommerce_resources
sync_products(woocommerce_settings.price_list, woocommerce_settings.warehouse)
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/sync_products.py”, line 19, in sync_products
sync_erpnext_items(price_list, warehouse, woocommerce_item_list)
File “/home/frappe/bench12/apps/woocommerceconnector/woocommerceconnector/sync_products.py”, line 139, in sync_erpnext_items
make_woocommerce_log(title=e.message, status=“Error”, method=“sync_woocommerce_items”, message=frappe.get_traceback(),
AttributeError: ‘HTTPError’ object has no attribute ‘message’

This seems to be the same error as observed by @zerodiscount when trying to sync the items between WooCommerce and ERPNext. How is your configuration, can you sync the IDs? Do you have th items in ERPNext first and want to sync the to WooCommerce or the other way?

Yes i have the items in ERPNext first , which then syncs to the website.

Yes i can sync IDs but each time i use the sync ID it duplicates the item on the website.

Please help
Sync was successful (Woocommerce to erpnext) but items are not reflected in Erpnext. What did i missed?
Items Sync was successful (Erpnext to Woocommerce)

This is Mostly due to the below error
CRITICAL Uncaught Error: Call to a member function get_cart_subtotal() on null in /var/www/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php:77

If this is the case you can enable permalinks in the Wordpress. Setting->Permalinks->Common Settings.
Choose Post Name and save the settings.

The cause is the theme used does not have the default permalinks activated. Very simple and Misguiding issues

thanks @gsarunk will review this and revert

1 Like

For me Id sync just starting but never gets completed. Due to this I am not able to perform Sync Woocommerce. This ends with WooCommerce Id not synced error. I am sure this should be a small glitch. Experts must be knowing what I am missing :slight_smile:

@gsarunk no one has been able to make this sync work

Regards

@olamide_shodunke The Request is able to pull the Product data along with the Woocommerce ID of the product from the WooCommerce instance when we trigger Id ‘Sync Woocommerce Ids to ERP’. The problem I see is that method ‘add_w_id_to_erp’ is not updating the retrieved information back to ERPNext.
Other thing could be the Core Integration Module ‘Woocommerce Setting’ is also having a woocommerce Id for the product. I guess this ignored by the Woocommerce connector because product replicated from woocommerce during order creation by the Core Integration module is again replicated back as a new product in the woocommerce when we sync using connector.

Anyways i will wait for someone with a success :slight_smile:

@olamide_shodunke @EnSeal,
I have reported an issue in github. I have found the problem. This should be a small fix.
https://github.com/libracore/WooCommerceConnector/issues/26

The logic is your ERPNext Barcode is the sku in Woocommerce. Products only sync based on these two relation.
The problem is barcode field in now barcodes. Until the code is adjusted to this new field the sync will only dump…

2 Likes

Hi @gsarunk,
thanks. Yes, the barcode field was removed in v12 (without a backwards compatible invisible field, as would be better).

We have resolved this with a fixture:
https://github.com/libracore/WooCommerceConnector/commit/b200df5658f22e5fae959678bdb605d1acf3482f

You might want to consider to add a custom script to update the field automatically, such as

frappe.ui.form.on("Item", {
  validate: function(frm) {
      // v12 dropped the barcode field --> on save, restore
      retrofit_barcodes(frm);
  }
});

function retrofit_barcodes(frm) {
    try {
        var barcode = frm.doc.barcodes[0].barcode;
        cur_frm.set_value('barcode', barcode);
    } catch (e) { /* do nothing */ }
}
2 Likes