Advertisement
Guest User

Untitled

a guest
May 30th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. import psycopg2, sys, psycopg2.extras, time
  2.  
  3. order = 4419
  4.  
  5. try:
  6. con = psycopg2.connect(host='localhost', database='DB01', user='odoo', password='******')
  7. cur = con.cursor()
  8. po_lines = 'SELECT pos_order_line.id FROM public.pos_order_line, public.product_template '
  9. 'WHERE pos_order_line.product_id = product_template.id AND pos_order_line.order_id = %s '
  10. 'AND (product_template.pos_categ_id != 5 AND product_template.pos_categ_id != 6)'
  11. 'ORDER BY pos_order_line.id ASC'
  12. po_lines2 = 'SELECT pos_order_line.id, pos_order_line.order_id, product_template.name, pos_order_line.qty, product_template.pos_categ_id '
  13. 'FROM public.pos_order_line, public.product_template '
  14. 'WHERE pos_order_line.product_id = product_template.id AND pos_order_line.id = %s '
  15. 'ORDER BY pos_order_line.id ASC'
  16.  
  17. cur.execute(po_lines,[order]); fetch_lines = cur.fetchall()
  18. dish = ''; instr = []; kot = 0; dp = 0
  19. print fetch_lines
  20. for line in fetch_lines:
  21. cur.execute(po_lines2, [line]); pos_lines = cur.fetchone()
  22. if pos_lines[2].startswith('#'):
  23. instr.insert(1, pos_lines[2][2:]); kot = 1
  24. elif pos_lines[2].startswith('----'):
  25. dp = 1
  26. else:
  27. dish = pos_lines[2]
  28. kot = 0; instr = []
  29. if dp == 1:
  30. instr.insert(0, '!SERVIR DEPOIS!'); dp = 0
  31. if dish != pos_lines[2]:
  32. print 'Ordem: ', order, ' - Prato:', dish, ' - Instr:', instr, 'qt: ', pos_lines[3],'kot: ', kot, 'dp status:', dp
  33.  
  34. except psycopg2.DatabaseError, e:
  35. print 'Error %s' % e
  36. sys.exit(1)
  37.  
  38. finally:
  39. if con:
  40. con.close()
  41.  
  42. ID ORDER PRODUCT QTY CAT
  43. 12811 4419 "Crudo GR" 1.0 1
  44. 12812 4419 "Salame e Grana GR" 1.0 1
  45. 12813 4419 "---- servir depois ----" 1.0 7
  46. 12814 4419 "Nutella Ban GR" 1.0 3
  47. 12815 4419 "# Cortar em dois" 1.0 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement