def init_n_connect(flavour=None): title = 'Import partners %s' % flavour or '' parser = z0lib.parseoptargs(title, "© 2017-2018 by SHS-AV s.r.l.", version=__version__) parser.add_argument('-h') parser.add_argument("-c", "--config", help="configuration command file", dest="conf_fn", metavar="file", default='./import_partners.conf') parser.add_argument("-d", "--dbname", help="DB name", dest="db_name", metavar="file", default='demo8') parser.add_argument("-e", "--customer", help="Import customers", action="store_true", dest="customers", default=False) parser.add_argument("-f", "--filename", help="Filename to import", dest="csv_fn", metavar="file", default=False) parser.add_argument('-n') parser.add_argument('-q') parser.add_argument("-s", "--supplier", help="Import suppliers", action="store_true", dest="suppliers", default=False) parser.add_argument('-V') parser.add_argument('-v') # Connect to DB ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) ctx['flavour'] = flavour if not ctx['customers'] and not ctx['suppliers']: print "You must select customers and/or supplier" sys.exit(1) if not ctx['csv_fn']: if flavour: sfx = '_' else: sfx = '' if ctx['customers']: ctx['csv_fn'] = 'customers%s%s.csv' % (sfx, flavour or '') else: ctx['csv_fn'] = 'suppliers%s%s.csv' % (sfx, flavour or '') oerp, uid, ctx = clodoo.oerp_set_env(confn=ctx['conf_fn'], db=ctx['db_name'], ctx=ctx) ctx['TRX_country_id'] = {'inghilterra': 'Regno Unito', 'Inghilterra': 'Regno Unito'} ctx['TRX_is_company'] = {'$BOOLEAN': '', } ctx['TRX_individual'] = {'$BOOLEAN': '', } ctx['default_country_id'] = get_country_id(ctx, 'Italia') ctx['default_is_company'] = True return oerp, uid, ctx
def init_n_connect(flavour=None): title = 'Update Chart of Account' parser = z0lib.parseoptargs(title, "© 2017-2018 by SHS-AV s.r.l.", version=__version__) parser.add_argument('-h') parser.add_argument("-c", "--config", help="configuration command file", dest="conf_fn", metavar="file", default='./import_partners.conf') parser.add_argument("-d", "--dbname", help="DB name", dest="db_name", metavar="file", default='') parser.add_argument('-n') parser.add_argument('-q') parser.add_argument('-V') parser.add_argument('-v') # Connect to DB ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) oerp, uid, ctx = clodoo.oerp_set_env(confn=ctx['conf_fn'], db=ctx['db_name'], ctx=ctx) return oerp, uid, ctx
def init_n_connect(flavour=None): title = 'Import products %s' % flavour or '' parser = z0lib.parseoptargs(title, "© 2017-2018 by SHS-AV s.r.l.", version=__version__) parser.add_argument('-h') parser.add_argument("-c", "--config", help="configuration command file", dest="conf_fn", metavar="file", default='./import_products.conf') parser.add_argument("-d", "--dbname", help="DB name", dest="db_name", metavar="file", default='demo8') parser.add_argument("-f", "--filename", help="Filename to import", dest="csv_fn", metavar="file", default=False) parser.add_argument('-n') parser.add_argument('-q') parser.add_argument('-V') parser.add_argument('-v') # Connect to DB ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) ctx['flavour'] = flavour if not ctx['csv_fn']: if flavour: sfx = '_' else: sfx = '' ctx['csv_fn'] = 'products%s%s.csv' % (sfx, flavour or '') oerp, uid, ctx = clodoo.oerp_set_env(confn=ctx['conf_fn'], db=ctx['db_name'], ctx=ctx) return oerp, uid, ctx
parser.add_argument("-d", "--dbname", help="DB name to connect", dest="db_name", metavar="file", default='') parser.add_argument('-n') parser.add_argument('-q') parser.add_argument('-V') parser.add_argument('-v') UPDATE = True # Connect to DB print "Connect to DB" ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) oerp, uid, ctx = clodoo.oerp_set_env(confn=ctx['conf_fn'], db=ctx['db_name'], ctx=ctx) # Recognize environment hostname = platform.node() if hostname[0:3] == 'shs': PRODUCT_TMPL_ID = 197 PRODUCT_ID = 200 model = 'res.company' company_id = oerp.search(model, [('name', 'ilike', 'La Tua Azienda')])[0] else: PRODUCT_TMPL_ID = 2 PRODUCT_ID = 2 company_id = 1 model = 'stock.warehouse' warehouse_id = oerp.search(model, [('company_id', '=', company_id)])[0] model = 'res.partner'
dest="left_db_name", metavar="name", default='demo') parser.add_argument('-n') parser.add_argument('-q') parser.add_argument('-V') parser.add_argument('-v') parser.add_argument("-w", "--right-config", help="configuration command file", dest="right_conf_fn", metavar="file", default='./inv2draft_n_restore.conf') parser.add_argument("-x", "--right-db_name", help="Database name", dest="right_db_name", metavar="name", default='demo') left_ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) right_ctx = left_ctx.copy() left_ctx['db_name'] = left_ctx['left_db_name'] left_ctx['conf_fn'] = left_ctx['left_conf_fn'] right_ctx['db_name'] = right_ctx['right_db_name'] right_ctx['conf_fn'] = right_ctx['right_conf_fn'] uid, right_ctx = clodoo.oerp_set_env(ctx=right_ctx) uid, left_ctx = clodoo.oerp_set_env(ctx=left_ctx) transodoo.read_stored_dict(right_ctx) left_ctx['mindroot'] = right_ctx['mindroot']
parser = parseoptargs("Set invoice status", "© 2017-2018 by SHS-AV s.r.l.", version=__version__) parser.add_argument('-h') parser.add_argument("-c", "--config", help="configuration command file", dest="conf_fn", metavar="file", default='./inv2draft_n_restore.conf') parser.add_argument('-n') parser.add_argument('-q') parser.add_argument('-V') parser.add_argument('-v') ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) oerp, uid, ctx = clodoo.oerp_set_env(ctx=ctx) print "Invoice set Draft and Restore - %s" % __version__ HDRDTL = {} for search_mode in (':A:', ':C:'): HDRDTL[search_mode] = 'D' for search_mode in (':I:', ':N:', ':P:'): HDRDTL[search_mode] = 'H' INVMOV = {} for action in ('P', 'U', 'X'): INVMOV[action] = 'M' for action in ('B', 'C', 'D', 'N', 'R', 'S', 'V'): INVMOV[action] = 'I' MODEL = { 'MH': 'account.move', 'MD': 'account.move.line', 'IH': 'account.invoice',
help="original DB", dest="old_db", metavar="file", default='cscs2016') parser.add_argument('-q') parser.add_argument("-t", "--table", help="table to select", dest="sel_tbl", metavar="file", default='') parser.add_argument('-V') parser.add_argument('-v') # Connect to DB ctx = parser.parseoptargs(sys.argv[1:], apply_conf=False) oerp, uid, ctx = clodoo.oerp_set_env(confn=ctx['conf_fn'], db=ctx['new_db'], ctx=ctx) ctx['db_name'] = ctx['old_db'] cr_old = clodoo.psql_connect(ctx) ctx['db_name'] = ctx['new_db'] cr_new = clodoo.psql_connect(ctx) print "Recover DB %s from DB %s" % (ctx['new_db'], ctx['old_db']) SCHEMA_NAME = 'public' SCHEMA_SQL = "SELECT table_name FROM information_schema.tables " \ "WHERE table_schema='%s' and table_type<>'VIEW';" COLUMN_SQL = "SELECT column_name,data_type,is_nullable,numeric_precision," \ "numeric_scale,character_maximum_length " \ "from information_schema.columns " \ "where table_schema = '%s' and table_name='%s'" COL_STRUCT = ('type', 'null', 'precision', 'scale', 'len')