Пример #1
0
    'country_id/id':
    mapper.map_val('country', country_map),
    'customer':
    mapper.const('1'),
    'lang':
    mapper.map_val('Language', lang_map),
    'image':
    mapper.binary("Image", "origin/img/"),
    'create_uid':
    mapper.val('Create BY'),
    'create_date':
    mapper.val('Create ON',
               postprocess=lambda x: datetime.strptime(x, "%d/%m/%y").strftime(
                   "%Y-%m-%d 00:00:00")),
    'category_id/id':
    mapper.m2m(PARTNER_CATEGORY_PREFIX, 'Tag', 'Fidelity Grade'),
}

tag_mapping = {
    'id': mapper.m2m_id_list(PARTNER_CATEGORY_PREFIX, 'Tag'),
    'name': mapper.m2m_value_list('Tag'),
}

grade_mapping = {
    'id': mapper.m2m_id_list(PARTNER_CATEGORY_PREFIX, 'Fidelity Grade'),
    'name': mapper.m2m_value_list('Fidelity Grade'),
}

#Step 4: Process data
processor.process(tag_mapping,
                  'data%sres.partner.category.csv' % os.sep, {},
Пример #2
0
mapping = {
    'id': mapper.m2o(PARTNER_PREFIX, 'id'),
    'name': mapper.val('id', postprocess=lambda x: "Partner %s" % x),
    'phone': mapper.val('id', postprocess=lambda x: "0032%s" % (int(x) * 11)),
    'website': mapper.val('id',
                          postprocess=lambda x: "http://website-%s.com" % x),
    'street': mapper.val('id', postprocess=lambda x: "Street %s" % x),
    'city': mapper.val('id', postprocess=lambda x: "City %s" % x),
    'zip': mapper.val('id', postprocess=lambda x: ("%s" % x).zfill(6)),
    'country_id/id': mapper.const('base.be'),
    'company_type': mapper.const('company'),
    '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',
                  },
Пример #3
0
data = [[str(i), ','.join(tags[random.randint(0, 99)] for i in range(0, 5))] for i in range(0, 200)]

mapping = {
    'id': mapper.m2o(PARTNER_PREFIX, 'id'),
    'name': mapper.val('id', postprocess=lambda x: "Partner %s" % x),
    'phone': mapper.val('id', postprocess=lambda x: "0032%s" % (int(x) * 11)),
    'website': mapper.val('id', postprocess=lambda x: "http://website-%s.com" % x),
    'street': mapper.val('id', postprocess=lambda x: "Street %s" % x),
    'city': mapper.val('id', postprocess=lambda x: "City %s" % x),
    'zip': mapper.val('id', postprocess=lambda x: ("%s" % x).zfill(6)),
    'country_id/id': mapper.const('base.be'),
    'company_type': mapper.const('company'),
    '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, {