def handle(self, *args, **kwargs): for beerinst in BeerInst.objects.all(): beerinst.reconcile_stock() if beerinst.stock_total < 0: # Create a dummy StockImport, and StockMoved si = Stock(beerinst=beerinst, quantity=beerinst.stock_total * -1, comment="Auto created by negative_stock_fix") # To neutralise these numbers. si.save() print(beerinst) print(si) beerinst.save()
def _apply_actions(self, actions): for act in actions['add']: st = Stock(beerinst=act[0], quantity=act[1], comment="Stock take addition") st.save() print("%s \n" % st) for act in actions['write off']: sw = StockWriteOff(beerinst=act[0], quantity=act[1], comment="Stock take removal") sw.save() print("%s \n" % sw) # * A further reconcilation is triggered. self._reconcile() self._validate_complete()
def stock_import(self, beerinst, quantity): si = Stock(beerinst=beerinst, quantity=quantity) si.clean() si.save() messages.success(self.request, 'Beer added %s : %s' % (beerinst, quantity))