Is there a recommended ERPNext version for the WooCommerceConnector from Libracore?

I’ve been spinning my wheels getting the integration working. Invariably when it comes to syncing orders, it throws an error about due date can’t be before posting date. This is an initial sync from a running WooCommerce store where the orders are from a few days ago.

Anyone got this working and can share some tips?

1 Like

You could try inserting the data in the DB using a function which disables these checks.
Just find them in the document API documentation for frappe framework.

E.g.:

https://frappeframework.com/docs/user/en/api/document#doc-db-insert-

doc.db_insert()

Serialize and insert a document into database. Warning: This bypasses all validations and controller methods that might be required to run before and after inserting.

This is the full text of the error it’s throwing:

Traceback (most recent call last):
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 30, in sync_woocommerce_orders
create_order(woocommerce_order, woocommerce_settings)
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 164, in create_order
so = create_sales_order(woocommerce_order, woocommerce_settings, company)
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 225, in create_sales_order
so.save(ignore_permissions=True)
File “apps/frappe/frappe/model/document.py”, line 310, in save
return self._save(*args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 332, in _save
return self.insert()
File “apps/frappe/frappe/model/document.py”, line 261, in insert
self.run_before_save_methods()
File “apps/frappe/frappe/model/document.py”, line 1052, in run_before_save_methods
self.run_method(“validate”)
File “apps/frappe/frappe/model/document.py”, line 941, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1259, in composer
return composed(self, method, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1241, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “apps/frappe/frappe/model/document.py”, line 938, in fn
return method_object(*args, **kwargs)
File “apps/erpnext/erpnext/selling/doctype/sales_order/sales_order.py”, line 44, in validate
super(SalesOrder, self).validate()
File “apps/erpnext/erpnext/controllers/selling_controller.py”, line 32, in validate
super(SellingController, self).validate()
File “apps/erpnext/erpnext/controllers/stock_controller.py”, line 38, in validate
super(StockController, self).validate()
File “apps/erpnext/erpnext/controllers/accounts_controller.py”, line 166, in validate
self.validate_all_documents_schedule()
File “apps/erpnext/erpnext/controllers/accounts_controller.py”, line 272, in validate_all_documents_schedule
self.validate_non_invoice_documents_schedule()
File “apps/erpnext/erpnext/controllers/accounts_controller.py”, line 265, in validate_non_invoice_documents_schedule
self.validate_payment_schedule_dates()
File “apps/erpnext/erpnext/controllers/accounts_controller.py”, line 1684, in validate_payment_schedule_dates
frappe.throw(
File “apps/frappe/frappe/init.py”, line 504, in throw
msgprint(
File “apps/frappe/frappe/init.py”, line 479, in msgprint
_raise_exception()
File “apps/frappe/frappe/init.py”, line 434, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Row 1: Due Date in the Payment Terms table cannot be before Posting Date

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “apps/woocommerceconnector/woocommerceconnector/api.py”, line 52, in sync_woocommerce_resources
sync_orders()
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 15, in sync_orders
sync_woocommerce_orders()
File “apps/woocommerceconnector/woocommerceconnector/sync_orders.py”, line 37, in sync_woocommerce_orders
if e.args and e.args[0] and e.args[0].decode(“utf-8”).startswith(“402”):
AttributeError: ‘str’ object has no attribute ‘decode’

1 Like

So I sorted this out, and it’s not a source code issue. It’s an undocumented ERPNext configuration requirement issue.

In case anyone ever comes across this via Google:

  1. You need to create a Payment Term Template. Name it whatever you want, but make it something easy. Set it for Days after Invoice Date, 100%, and whatever number you feel is apporpriate. Checkmark the Allocate Payment Based on Payment Terms checkbox. If you need different settings, it’s up to you to test and determine appropriate settings based on desired behavior. I did 100%, 7 days.
  2. Customize the Sales Order form, go to page 3, edit the Payment Terms Template, drop the name of your template into the Default box, click out then Update.
2 Likes

The woocommerce connector of libracore works 100% both in individual products and with variants in ERPNExt version 14, you have to fix the errors that occur, but it works, orders, products and customers are synchronized and depending on your configuration even the sales invoice makes it and the payment if you use Stripe registers it.

Hi Terry, are you using the regular vs14 integration or the libracore one?

Libracore.

And I’m still hoping someone has a specific version of 13 or 14 they recommend - because I still have issues with the 13 image I’m using although it does work.

1 Like

What inconveniences do you have…maybe I can help you.

This is the error log that it pops most often.

This is actually not an error. The response from this call is 201 which is successful write but the log expected 200 only so it logs this as an error. Whenever you see this, ignore it or go to the requests and update the post request function with this:

def post_request(path, data):
        settings = get_woocommerce_settings()
        
        wcapi = API(
                url=settings['woocommerce_url'],
                consumer_key=settings['api_key'],
                consumer_secret=settings['api_secret'],
                verify_ssl=settings['verify_ssl'],
                wp_api=True,
                version="wc/v3",
                # query_string_auth=True,
                timeout=1000
        )
        
        r = wcapi.post(path, data)
        
        #r.raise_for_status()
        # manually raise for status to get more info from error (message details)
        if r.status_code not in (requests.codes.ok, requests.codes.created):
            make_woocommerce_log(title="WooCommerce post error {0}".format(r.status_code), 
                status="Error", 
                method="post_request", 
                message="{0}: {1}".format(r.url, r.json()),
                request_data=data, 
                exception=True)
        return r.json()

This will ensure all post requests with 200 - 300 response are treated as success responeses.

1 Like

Check if this helps you