Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. def test_run_sql_query():
  2.     conn = psycopg2.connect("dbname=production_dev user=openerp password=endKjw7hdHHG host=dodman.erp.zone")
  3.     cur = conn.cursor()
  4.     cur.execute("""
  5.    SELECT so.name,
  6.    so.state, so.create_date, so.write_date,
  7.        so.id,
  8.        ROUND(so.amount_untaxed) - ROUND(sum(sol.product_uom_qty*sol.price_unit))
  9.    FROM sale_order so
  10.    LEFT JOIN sale_order_line sol ON so.id = sol.order_id
  11.    WHERE so.state != 'cancel'
  12.    AND sol.optional IS NOT TRUE
  13.    GROUP BY so.id
  14.    HAVING abs(ROUND(so.amount_untaxed,2) - ROUND(sum(sol.product_uom_qty*sol.price_unit),2)) > 0.1
  15.    order by so.create_date DESC
  16.    """)
  17.     result = cur.fetchall()
  18.     print result
  19.     assert not result
  20.     cur.close()
  21.     conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement