tangentlabs/django-oscar — pull request #661 by st4lk (2013-05-01 21:22:11+00:00)
Title: #658 reduce db calls at product list page

On fetching Products from db, all needed information is gathered with select_related and prefetch_related in [get_product_base_queryset](https://github.com/tangentlabs/django-oscar/blob/master/oscar/apps/catalogue/views.py#L87).
But, function [DefaultWrapper.max_purchase_quantity](https://github.com/tangentlabs/django-oscar/blob/master/oscar/apps/partner/wrappers.py#L39) access to product through stockrecord. Product and StockRecord has OneToOne relation, so product == product.stockrecord.product. But last one will access database one more time. And, consequently, furcher attempts on product will also make db call: stockrecord.product.get_product_class().

Idea of this commit is to use fetched product, and not a stockrecord.product.