Payment modules not respecting TRACK_INVENTORY configuration

Issue #1424 resolved
Darren Hollenbeck
created an issue

It looks like two of the payment modules are not using the listener functionality for order_success to call decrease_inventory_on_sale() and instead implement the same code in that function on their own, //without// respecting the configuration variable to track inventory (or not).

Offending segments: {{{

!python

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()

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() }}}

'normal' code which respects the configuration value (implemented as listener for signals): {{{

!python

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() }}}

Files attached are the ones containing the code segments.

Comments (1)

  1. Log in to comment