Exemple #1
0
 def send_in_the_kitchen(self):
     """We send the first category available to the kitchen.
     """
     if self.category_to_follow:
         follow = Follow(category=self.category_to_follow)
         follow.save()
         todolist = []
         heure = follow.date.strftime("%H:%M")
         # heure = datetime.datetime.now().strftime("%H:%M")
         todolist.append("[%s] Table %s (%s couv.)" % (heure, self.table,
                                                       self.couverts))
         todolist.append(">>> envoye %s" % follow.category.nom)
         todolist.append(" ")
         nb_products_sent = self.produits.filter(sent=True).count()
         # liste des produits qui doivent etre envoyés en cuisine
         products = []
         for product in self.produits.iterator():
             if product.est_un_menu():
                 # on veut les produits du menu
                 for sub in product.contient.iterator():
                     if not sub.sent and sub.made_with == follow.category:
                         sub.sent = True
                         products.append(sub)
                         follow.produits.add(sub)
                         sub.save()
             else:
                 if not product.sent \
                    and product.made_with == follow.category:
                     product.sent = True
                     products.append(product)
                     follow.produits.add(product)
                     product.save()
         if nb_products_sent == 0:
             # on crée le ticket avec la liste des produits et
             # des suites
             products = self.get_first_todolist_for_kitchen()
             if products:
                 todolist += products
         else:
             products.sort()
             for product in products:
                 todolist.append(product)
         for printer in Printer.objects.filter(kitchen=True):
             result = printer.regroup_list_and_print(todolist,
                                                     "kitchen-%s-%s" % (
                                                     self.id, 
                                                     follow.category.id))
             if not result:
                 return False
         follow.save()
         self.following.add(follow)
         self.something_for_the_kitchen()
         return True
Exemple #2
0
 def print_ticket_kitchen(self):
     """Prepare and send ticket to printers in kitchen."""
     output = True
     if self.category_to_follow:
         follow = Follow(category=self.category_to_follow)
         follow.save()
         todolist = []
         # header
         time = follow.date.strftime("%H:%M")
         todolist.append("[%s] Table %s (%s couv.)" %
                         (time, self.table, self.couverts))
         todolist.append(">>> faire: %s" % follow.category.nom)
         todolist.append(" ")
         # list of products to prepare (without Menu)
         products = self.get_products_for_category(follow.category)
         todolist += self.prepare_products(products)
         follow.produits = products
         follow.save()
         self.following.add(follow)
         # save send status
         for product in products:
             product.sent = True
             product.save()
         self.update_kitchen()
         # if another category following, we send it too to inform kitchen
         if self.category_to_follow:
             todolist.append(" ")
             category = self.category_to_follow
             todolist.append("Ensuite, pour info: %s" % category)
             products = self.get_products_for_category(category)
             todolist += self.prepare_products(products)
         # we print for each printers in kitchen
         name = "kitchen-%s-%s" % (self.id, follow.category_id)
         for printer in Printer.objects.filter(kitchen=True):
             if not printer.print_list(todolist, name, kitchen=True):
                 output = False
     return output
Exemple #3
0
 def print_ticket_kitchen(self):
     """Prepare and send ticket to printers in kitchen."""
     output = True
     if self.category_to_follow:
         follow = Follow(category=self.category_to_follow)
         follow.save()
         todolist = []
         # header
         time = follow.date.strftime("%H:%M")
         todolist.append("[%s] Table %s (%s couv.)" % (time, self.table,
                                                       self.couverts))
         todolist.append(">>> faire: %s" % follow.category.nom)
         todolist.append(" ")
         # list of products to prepare (without Menu)
         products = self.get_products_for_category(follow.category)
         todolist += self.prepare_products(products)
         follow.produits = products
         follow.save()
         self.following.add(follow)
         # save send status
         for product in products:
             product.sent = True
             product.save()
         self.update_kitchen()
         # if another category following, we send it too to inform kitchen
         if self.category_to_follow:
             todolist.append(" ")
             category = self.category_to_follow
             todolist.append("Ensuite, pour info: %s" % category)
             products = self.get_products_for_category(category)
             todolist += self.prepare_products(products)
         # we print for each printers in kitchen
         name = "kitchen-%s-%s" % (self.id, follow.category_id)
         for printer in Printer.objects.filter(kitchen=True):
             if not printer.print_list(todolist, name):
                 output = False
     return output