Mercurial > hgweb > health
view tryton/scripts/upgrade/2.0/pre.py @ 918:49292f265e45
health : Fix prescription report error when end date is empty
| author | Luis Falcon <lfalcon@gnusolidario.org> |
|---|---|
| date | Tue, 23 Jul 2013 21:45:05 -0300 |
| parents | |
| children | 5e524cec5295 |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System # Copyright (C) 2008-2013 Luis Falcon <lfalcon@gnusolidario.org> # Bruno M. Villasanti <bvillasanti@thymbra.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import optparse import psycopg2 def main(pg_cursor): pg_cursor.execute('UPDATE "ir_model_data" ' 'SET inherit = %s ' 'WHERE fs_id like \'prod_em%%\' ' ' AND model = %s AND module = %s ', (False, 'product.template', 'health',)) if __name__ == '__main__': parser = optparse.OptionParser(version='0.1') parser.add_option('--pg', dest='dsn', help='dsn for PostgreSQL') opt, args = parser.parse_args() pg_conn = None pg_cursor = None try: print ">> Attempting to connect..." pg_conn = psycopg2.connect(opt.dsn) print ">> Contected!" pg_cursor = pg_conn.cursor() main(pg_cursor) pg_conn.commit() print ">> Successfully prepared for migration!" finally: if pg_cursor: pg_cursor.close() if pg_conn: pg_conn.close()
