Models and Mixins¶
- class oscar_mws.mixins.AmazonStockTrackingMixin¶
A mixin to make stock tracking for Amazon MWS fulfilled products possible. The way stock tracking works in Oscar doesn’t play nicely with the details returned from MWS. Basically Amazon provides a single value which is the amount of items still available to be fulfilled. In Oscar, we track the number in stock as well as the allocated number of products. num_in_stock - num_allocated is the number of items actually avaiable to buy and both number in stock and number allocated are only decremented whenever an item is marked as shipped.
To handle this properly and be able to synchronise the fulfillable number of products available from Amazon, we use this mixin to override the
This is used when an item is shipped. We remove the original allocation and adjust the number in stock accordingly
Parameters: quantity (integer) – The quantity to be consumed.
Checks whether this stock record is associated with an Amazon merchant account.
Rtype bool: True if the stockrecord is Amazon stock, False otherwise.
- set_amazon_supply_quantity(quantity, commit=True)¶
Convenience method to set the field num_in_stock to quantity and reset the allocated stock in num_allocated to zero. We don’t care about allocation for MWS stock and therefore just reset it.
- quantity (integer) – The quantity currently available on Amazon for Fulfillment by Amazon (FBA).
- commit (boolean) – Allows to prevent immediate saving of the changes to the database. This is useful if you want to save on database queries when making other changes to the stock record.