Решение:
Как и советовали, количество товара на складе вынес в отделное поле для товара(а цены храняться в stockrecord). В stockrecord, количество сделал ссылкой на количество тпродукта.
class Product(AbstractProduct):
...
num_in_stock_product = models.PositiveIntegerField(
_("Number in stock(product)"), blank=True, null=True)
stock_update = models.IntegerField(
_("Stock update"), blank=True, null=True)
def save(self, *args, **kwargs):
if self.stock_update:
if not self.num_in_stock_product:
self.num_in_stock_product = 0
self.num_in_stock_product += self.stock_update
self.stock_update = None
super(AbstractProduct, self).save(*args, **kwargs)
self.attr.save()
class StockRecord(AbstractStockRecord):
...
@property
def num_in_stock_stockrecord(self):
return self.product.num_in_stock_product
@property
def net_stock_level(self):
"""
The effective number in stock (eg available to buy).
This is correct property to show the customer, not the num_in_stock
field as that doesn't account for allocations. This can be negative in
some unusual circumstances
"""
all_allocations = 0
for stockrecord in self.product.stockrecords.all():
if stockrecord.num_allocated is not None:
all_allocations += stockrecord.num_allocated
if self.num_in_stock_stockrecord is None:
return 0
return self.num_in_stock_stockrecord - all_allocations
Ну и переделал формы/вьюшки/и т.п. для нового поля num_in_stock_stockrecord(было num_in_stock)