Untitled
unknown
plain_text
a year ago
488 B
5
Indexable
Never
class StorageToSellHistory(models.Model): storage = models.ForeignKey(Storage, on_delete=models.SET_NULL, null=True) sell_history = models.ForeignKey(SellHistory, on_delete=models.SET_NULL, null=True) def save(self, *args, **kwargs): storage = self.storage if storage.storage_amount > 0: storage.storage_amount -= 1 storage.sold_amount += 1 storage.save() super(StorageToSellHistory, self).save(*args, **kwargs)