from oscar.apps.catalogue.abstract_models import AbstractProduct
from oscar.core.loading import get_classes
from django.conf import settings

StockRecord, Partner = get_classes('partner.models', ('StockRecord', 'Partner'))


class Product(AbstractProduct):

    @property
    def cost_price(self):
        # oscar has the prices and stock in a stockrecord model
        # in this case, we just use the first stockrecord, always
        if self.has_stockrecords:
            return self.stockrecords.first().cost_price
        else:
            return 0

    @property
    def num_in_stock(self):
        if self.has_stockrecords:
            return self.stockrecords.first().num_in_stock
        else:
            return 0

    def set_stockrecord(self, cost_price, num_in_stock):
        if self.has_stockrecords:
            stockrecord = self.stockrecords.first()
        else:
            # when creating a new stockrecord, we make some assumptions here:
            # there is only 1 partner
            # for sku we just use the product id with a prefix
            stockrecord = StockRecord.objects.create(
                partner=Partner.objects.first(), product=self, partner_sku='OD-%s'%self.pk, price_currency=settings.OSCAR_DEFAULT_CURRENCY
            )
        stockrecord.cost_price = cost_price
        stockrecord.num_in_stock = num_in_stock
        stockrecord.save()


from oscar.apps.catalogue.models import *  # noqa
@@ -222,40 +222,323 @@
 )%0A%0A%0A
-class Product(AbstractProduct):%0A
+# here we override the core oscar Product model%0Aclass Product(AbstractProduct):%0A    %0A    # the 2 main modification we are doing are:%0A    # 1. add properties for cost_price and num_in_stock%0A    # 2. add a function allowing to set those values%0A    # both these modifications will be used in the product edit form%0A    
 %0A   
@@ -995,24 +995,28 @@
    return 0%0A
+    
 %0A    def set
@@ -1447,21 +1447,55 @@
 (), 
-product=self,
+%0A                product=self, %0A               
  par
@@ -1520,16 +1520,33 @@
 elf.pk, 
+%0A                
 price_cu
@@ -1719,16 +1719,169 @@
 ave()%0A%0A%0A
+# this line must be after the model definitions%0A# it's a hack that allows overriding of core models and ensure proper integration with django migrations%0A
 from osc
@@ -1921,8 +1921,9 @@
   # noqa
+%0A

Update models.py