Пример #1
0
    '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, {
    'worker': 4,
    'batch_size': 100,
    'model': 'res.partner',
})
processor.write_output()
launchfile_write(processor.file_to_write,
                 script,
Пример #2
0
'''
Created on 10 dec. 2019

@author: Thibault Francois
'''
import random

from odoo_csv_tools.lib import transform


processor = transform.Processor(filename='origin/test_merge1.csv')
processor.join_file("origin/test_merge2.csv", "category", "name")