parser = argparse.ArgumentParser(description='Import data in batch and in parallel')
    parser.add_argument('-c', '--config', dest='config', default="conf/connection.conf",
                        help='Configuration File that contains connection parameters', required=True)
    parser.add_argument('--file', dest='filename', help='Output File', required=True)
    parser.add_argument('--model', dest='model', help='Model to Export', required=True)
    parser.add_argument('--field', dest='fields', help='Fields to Export', required=True)
    parser.add_argument('--domain', dest='domain', help='Filter', default="[]")
    parser.add_argument('--worker', dest='worker', default=1, help='Number of simultaneous connection')
    parser.add_argument('--size', dest='batch_size', default=10, help='Number of line to import per connection')
    parser.add_argument('-s', '--sep', dest="separator", default=";", help='CSV separator')
    parser.add_argument('--context', dest='context',
                        help='context that will be passed to the load function, need to be a valid python dict',
                        default="{'tracking_disable' : True}")
    # TODO args : encoding
    # {'update_many2many': True,'tracking_disable' : True, 'create_product_variant' : True, 'check_move_validity' : False}
    args = parser.parse_args()

    config_file = args.config
    file_csv = args.filename
    batch_size = int(args.batch_size)
    model = args.model
    max_connection = int(args.worker)
    separator = args.separator
    encoding = 'utf-8-sig'
    context = eval(args.context)
    domain = eval(args.domain)
    header = args.fields.split(',')
    export_threaded.export_data(config_file, model, domain, header, context=context, output=file_csv,
                                max_connection=max_connection, batch_size=batch_size, separator=separator,
                                encoding=encoding)
Exemple #2
0
    parser.add_argument(
        '--context',
        dest='context',
        help=
        'context that will be passed to the load function, need to be a valid python dict',
        default="{'tracking_disable' : True}")
    # TODO args : encoding
    # {'update_many2many': True,'tracking_disable' : True, 'create_product_variant' : True, 'check_move_validity' : False}
    args = parser.parse_args()

    config_file = args.config
    file_csv = args.filename
    batch_size = int(args.batch_size)
    model = args.model
    max_connection = int(args.worker)
    separator = args.separator
    encoding = 'utf-8-sig'
    context = eval(args.context)
    domain = eval(args.domain)
    header = args.fields.split(',')
    export_threaded.export_data(config_file,
                                model,
                                domain,
                                header,
                                context=context,
                                output=file_csv,
                                max_connection=max_connection,
                                batch_size=batch_size,
                                separator=separator,
                                encoding=encoding)