Fix: Removed that when there was nothign in order no commit add woud be done.
This commit is contained in:
parent
35f20e4f63
commit
321923b056
2 changed files with 15 additions and 9 deletions
|
|
@ -39,17 +39,21 @@ class compare:
|
|||
|
||||
OUT: True, False if succeded adding to db
|
||||
'''
|
||||
|
||||
if compare.verifie_order(ordered_list):
|
||||
#products = Product()
|
||||
order = Order(desk)
|
||||
session.add(order)
|
||||
session.commit()
|
||||
order = Order(desk)
|
||||
if compare.verifie_order(ordered_list):
|
||||
is_emtpy = True #check if nothing in prouduct if True dont commit.
|
||||
for product in ordered_list:
|
||||
if int(product[0]) > 0: #dont add not ordered to list
|
||||
if is_emtpy: #first time enter in loop
|
||||
session.add(order)
|
||||
session.commit()
|
||||
productDB = Product(quantity=int(product[0]),name=product[1],order_id = order.id)
|
||||
|
||||
session.add(productDB)
|
||||
session.add(productDB)
|
||||
is_emtpy = False
|
||||
if is_emtpy:
|
||||
return False
|
||||
|
||||
session.commit()
|
||||
logger.success("Order at desk "+ str(desk) +" resived")
|
||||
# add a new ordered_list to the database
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue