Payment modules not respecting TRACK_INVENTORY configuration

21 views
Skip to first unread message

Darren Hollenbeck

unread,
Jun 18, 2012, 11:11:27 AM6/18/12
to satchm...@googlegroups.com
I stumbled on this while doing some tweaks to my satchmo fork. Should I file it as an issue in the tracker?

In satchmo-trunk/satchmo/apps/payment/modules/paypal/views.py, line 227:
    # Added to track total sold for each product
    for item in order.orderitem_set.all():
        product = item.product
        product.total_sold += item.quantity
        product.items_in_stock -= item.quantity
        product.save()

In satchmo-trunk/satchmo/apps/payment/modules/google/notifications.py, line 60:
    # Added to track total sold for each product
    for item in order.orderitem_set.all():
        product = item.product
        product.total_sold += item.quantity
        product.items_in_stock -= item.quantity
        product.save()

The CORRECT code, (which I only see used by the downloadable product module) in satchmo-trunk/satchmo/apps/satchmo_store/shop/listeners.py, line 26:
def decrease_inventory_on_sale(sender, order=None, **kwargs):
    """Track inventory and total sold."""
    # Added to track total sold for each product
    for item in order.orderitem_set.all():
        product = item.product
        product.total_sold += item.quantity
        if config_value('PRODUCT','TRACK_INVENTORY'):
            product.items_in_stock -= item.quantity
        product.save()

Darren Hollenbeck

unread,
Jun 18, 2012, 11:38:28 AM6/18/12
to satchm...@googlegroups.com
On further investigation I see that the code which respects the configuration is bound to the order_success signal and is probably used in most cases, however that still doesn't resolve the two examples I posted where neither the signal code or even the correct configuration check is used.

Chris Moffitt

unread,
Jun 18, 2012, 2:40:45 PM6/18/12
to satchm...@googlegroups.com
Yes, please submit a ticket and I'll look into it.

-Chris

--
You received this message because you are subscribed to the Google Groups "Satchmo users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/satchmo-users/-/Rr5PuOr3ipYJ.

To post to this group, send email to satchm...@googlegroups.com.
To unsubscribe from this group, send email to satchmo-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.

Reply all
Reply to author
Forward
0 new messages