Permalink
Browse files

Added handling for missing stock record in catalogue form

  • Loading branch information...
1 parent 5ca255b commit 389dcad1aeea69c4b9c5434a3b4d468dc661dfaf @codeinthehole codeinthehole committed May 18, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 oscar/apps/dashboard/catalogue/views.py
@@ -153,7 +153,10 @@ class ProductUpdateView(generic.UpdateView):
def get_context_data(self, **kwargs):
ctx = super(ProductUpdateView, self).get_context_data(**kwargs)
if 'stockrecord_form' not in ctx:
- ctx['stockrecord_form'] = StockRecordForm(instance=self.object.stockrecord)
+ instance = None
+ if self.object.has_stockrecord:
+ instance=self.object.stockrecord
+ ctx['stockrecord_form'] = StockRecordForm(instance=instance)
if 'category_formset' not in ctx:
ctx['category_formset'] = ProductCategoryFormSet(instance=self.object)
if 'image_formset' not in ctx:

0 comments on commit 389dcad

Please sign in to comment.