Product model base implementation – you do not need to use this
It may save you some typing though.
Product models must have two methods to be usable with Plata:
get_price: Return a price instance
handle_order_item: Fill in fields on the order item from the product, i.e. the name and the stock keeping unit.
This method is part of the public, required API of products. It returns either a price instance or raises a
If you need more complex pricing schemes, override this method with your own implementation.
Exact, transactional stock tracking for Plata¶
Follow these steps to enable this module:
Ensure your product model has an
items_in_stockfield with the following definiton:
items_in_stock = models.IntegerField(default=0)
PLATA_STOCK_TRACKING = Trueto enable stock tracking in the checkout and payment processes.
Optionally modify your add-to-cart forms on product detail pages to take into account
A period in which stock changes are tracked
You might want to create a new period every year and create initial amount transactions for every variation.
StockTransaction.objects.open_new_perioddoes this automatically.
Stores stock transactions transactionally :-)
Stock transactions basically consist of a product variation reference, an amount, a type and a timestamp. The following types are available:
StockTransaction.INITIAL: Initial amount, used when filling in the stock database
StockTransaction.CORRECTION: Use this for any errors
StockTransaction.PURCHASE: Product purchase from a supplier
StockTransaction.SALE: Sales, f.e. through the webshop
StockTransaction.RETURNS: Returned products (i.e. from lending)
StockTransaction.INCOMING: Generic warehousing
StockTransaction.OUTGOING: Generic warehousing
StockTransaction.PAYMENT_PROCESS_RESERVATION: Product reservation during payment process
Most of these types do not have a significance to Plata. The exceptions are:
INITIALtransactions are created by
SALEtransactions are created when orders are confirmed
PAYMENT_PROCESS_RESERVATIONtransactions are created by payment modules which send the user to a different domain for payment data entry (f.e. PayPal). These transactions are also special in that they are only valid for 15 minutes. After 15 minutes, other customers are able to put the product in their cart and proceed to checkout again. This time period is a security measure against customers buying products at the same time which cannot be delivered afterwards because stock isn’t available.