Exemple #1
0
# STEP 5: Product Variant
product_mapping = {
    'id':
    mapper.m2o_map(PRODUCT_PREFIX,
                   mapper.concat('_', 'barcode', 'Color', 'Gender', 'Size_H',
                                 'Size_W'),
                   skip=True),
    'barcode':
    mapper.val('barcode'),
    'product_tmpl_id/id':
    mapper.m2o(TEMPLATE_PREFIX, 'ref'),
    'attribute_value_ids/id':
    mapper.m2m_attribute_value(ATTRIBUTE_VALUE_PREFIX, 'Color', 'Gender',
                               'Size_H', 'Size_W'),
}
processor.process(
    product_mapping, 'data%sproduct.product.csv' % os.sep, {
        'worker': 3,
        'batch_size': 50,
        'groupby': 'product_tmpl_id/id',
        'context': context
    }, 'set')

# Step 6: Define output and import parameter
processor.write_output()
launchfile_write(processor.file_to_write,
                 "3_product_import.sh",
                 python_exe='python-coverage run -a',
                 path='../')
Exemple #2
0
    'customer': mapper.val('id', postprocess=lambda x: str(int(x) % 2)),
    'supplier': mapper.val('id', postprocess=lambda x: str((int(x) + 1) % 2)),
    'lang': mapper.const('English'),
    'category_id/id': mapper.m2m(TAG_PREFIX, 'tags')
}

tag_mapping = {
    'id': mapper.m2m_id_list(TAG_PREFIX, 'tags'),
    'name': mapper.m2m_value_list('tags'),
    'parent_id/id': mapper.const('base.res_partner_category_0'),
}

processor = transform.Processor(header=header, data=data)
processor.process(tag_mapping,
                  tag_output, {
                      'worker': 1,
                      'batch_size': 10,
                      'model': 'res.partner.category',
                  },
                  m2m=True)
processor.process(mapping, output, {
    'worker': 4,
    'batch_size': 100,
    'model': 'res.partner',
})
processor.write_output()
launchfile_write(processor.file_to_write,
                 script,
                 python_exe='python-coverage run -a',
                 path='../')
Exemple #3
0
    'customer': mapper.val('id', postprocess=lambda x: str(int(x) % 2)),
    'supplier': mapper.val('id', postprocess=lambda x: str((int(x) + 1) % 2)),
    'lang': mapper.const('English'),
    'category_id/id': mapper.m2m(TAG_PREFIX, 'tags')
}

tag_mapping = {
    'id': mapper.m2m_id_list(TAG_PREFIX, 'tags'),
    'name': mapper.m2m_value_list('tags'),
    'parent_id/id': mapper.const('base.res_partner_category_0'),
}

processor = transform.Processor(header=header, data=data)
p_dict = processor.split(mapper.split_line_number(1000))  # Useless just for coverage
p_dict = processor.split(mapper.split_file_number(8))
processor.process(tag_mapping, tag_output, {
    'worker': 1,  # OPTIONAL
    'batch_size': 10,  # OPTIONAL
    'model': 'res.partner.category',
}, m2m=True)
processor.write_output()
launchfile_write(processor.file_to_write, script, path='../')
for index, p in p_dict.items():
    p.process(mapping, '%s.%s' % (output, index), {
        'worker': 4,  # OPTIONAL
        'batch_size': 100,  # OPTIONAL
        'model': 'res.partner',
    })
    p.write_output()
    launchfile_write(p.file_to_write, script, path='../', append=True)