libracore / WooCommerceConnector

Integration App for ERPNext to connect to WooCommerce
Other
88 stars 149 forks source link

Support for Virtual Products #58

Closed batonac closed 2 years ago

batonac commented 2 years ago

At the moment, the code seems to be coded with the assumption that all products will have a stock quantity, but of course this doesn't apply to virtual products, such as services and digital products.

The offending code is "apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 631:

def get_price_and_stock_details(item, warehouse, price_list):
    actual_qty = frappe.db.get_value("Bin", {"item_code":item.get("item_code"), "warehouse": warehouse}, "actual_qty")
    reserved_qty = frappe.db.get_value("Bin", {"item_code":item.get("item_code"), "warehouse": warehouse}, "reserved_qty")
    qty = actual_qty - reserved_qty

Here's the full error:

Traceback (most recent call last):
  File "apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 399, in sync_erpnext_items
    sync_item_with_woocommerce(item, price_list, warehouse, woocommerce_item_list.get(item.get('woocommerce_product_id')))
  File "apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 475, in sync_item_with_woocommerce
    item_data.update( get_price_and_stock_details(item, warehouse, price_list) )
  File "apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 631, in get_price_and_stock_details
    qty = actual_qty - reserved_qty
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

I "fixed" in the meantime by commenting out the qty line and making it null:

    # qty = actual_qty - reserved_qty
    qty = 0
lasalesi commented 2 years ago

Resolved in 4dd9b6d