Пример #1
0
            return 'IT{}'.format(val)
        if val[:2] == 'IT':
            if len(val) == 13 and val[:3].isdigit():
                return val.upper()
        if val[:2] in ('GB', 'EE', 'LT'):
            return val
    return ''


# STEP 1 : read the needed file(s)
processor = Processor('../data/NOMIN.CSV', conf_file=CONNECTION_FILE, delimiter=",")


# STEP 2 : Define the mapping for every object to import
mapping = {
    'id': mapper.m2o_map(PARTNER_PREFIX, mapper.val('CODICE')),
    'name': mapper.val('DESCRIZION', skip=True),
    'street': mapper.val('INDIRIZZO'),
    'city': mapper.val('COMUNE'),
    'zip': mapper.val('CAP'),
    'country_id/id': mapper.val('PAESE', postprocess=postprocess_country_id),
    'state_id/id': mapper.val('PROVINCIA', postprocess=postprocess_country_state_id),
    'vat': mapper.val('PARTITA_IV', postprocess=postprocess_vat),
    'phone': mapper.val('TELEFONO1'),
    'email': mapper.val('E_MAIL'),

    # OTHER
    'lang': mapper.val('PAESE', postprocess=postprocess_lang),
    'customer': mapper.const('1'),
    'supplier': mapper.const('1'),
Пример #2
0
    'value_ids/id': mapper.m2o_att(ATTRIBUTE_VALUE_PREFIX,
                                   attribute_list)  # TODO
}
processor.process_attribute_mapping(attribue_value_mapping, line_mapping,
                                    attribute_list, ATTRIBUTE_PREFIX, 'data/',
                                    {
                                        'worker': 3,
                                        'batch_size': 50,
                                        'context': context
                                    })

# 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
Пример #3
0
from odoo_csv_tools.lib import mapper
from odoo_csv_tools.lib.transform import Processor
from datetime import datetime

processor = Processor('client_file.csv', delimiter=';')
res_partner_mapping = {
    'id':
    mapper.m2o_map('my_import_res_partner',
                   mapper.concat('_', 'Firstname', 'Lastname', 'Birthdate')),
    'name':
    mapper.concat(' ', 'Firstname', 'Lastname'),
    'birthdate':
    mapper.val('Birthdate',
               postprocess=lambda x: datetime.strptime(x, "%d/%m/%y").strftime(
                   "%Y-%m-%d 00:00:00")),
}
processor.process(
    res_partner_mapping, 'res.partner.csv', {
        'model': 'res.partner',
        'context': "{'tracking_disable': True}",
        'worker': 2,
        'batch_size': 20
    })
processor.write_to_file("res_partner.sh", python_exe='', path='')
Пример #4
0
# STEP 4: Attribute List
attribute_list = ['Color', 'Gender', 'Size_H', 'Size_W']
attribue_value_mapping = {
    'id': mapper.m2o_att(ATTRIBUTE_VALUE_PREFIX, attribute_list),  # TODO
    'name': mapper.val_att(attribute_list),  # TODO
    'attribute_id/id': mapper.m2o_att_name(ATTRIBUTE_PREFIX, attribute_list),
}

line_mapping = {
    'product_tmpl_id/id': mapper.m2o(TEMPLATE_PREFIX, 'ref'),
    'attribute_id/id': mapper.m2o_att_name(ATTRIBUTE_PREFIX, attribute_list),
    'value_ids/id': mapper.m2o_att(ATTRIBUTE_VALUE_PREFIX, attribute_list)  # TODO
}
processor.process_attribute_mapping(attribue_value_mapping, line_mapping, attribute_list, ATTRIBUTE_PREFIX, 'data/',
                                    {'worker': 3, 'batch_size': 50, 'context': context})

# 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_to_file("3_product_import.sh", python_exe=EXEC, path='../')
Пример #5
0
# -*- coding: utf-8 -*-
import os
from odoo_csv_tools.lib import mapper
from odoo_csv_tools.lib.transform import Processor
from datetime import datetime
from prefix import *

#STEP 1 : read the needed file(s)
processor = Processor('origin%scontact.csv' % os.sep)

##STEP 2 : Define the mapping for every object to import
mapping = {
    'id':
    mapper.m2o_map(CLIENT_PREFIX, mapper.concat('_', 'Client Name',
                                                'zip code')),
    'name':
    mapper.val('Client Name', skip=True),
    'phone':
    mapper.val('Phone'),
    'street':
    mapper.val('address1'),
    'city':
    mapper.val('city'),
    'zip':
    mapper.val('zip code'),
    'country_id/id':
    mapper.map_val('country', country_map),
    'customer':
    mapper.const('1'),
    'lang':
    mapper.map_val('Language', lang_map),
# -*- coding: utf-8 -*-
from odoo_csv_tools.lib import mapper
from odoo_csv_tools.lib.transform import Processor
from datetime import datetime
from prefix import SUPPLIER_PREFIX, MESSAGE_PREFIX, SUPPLIER_CONTACT_PREFIX

#STEP 1 : read the needed file(s)
processor = Processor('origin/message.csv')

##STEP 2 : Define the mapping for every object to import
mapping = {
    'id':
    mapper.m2o_map(MESSAGE_PREFIX, mapper.concat("_", 'Company_ID', 'Date')),
    'res_external_id':
    mapper.m2o(SUPPLIER_PREFIX, 'Company_ID'),
    'author_id/id':
    mapper.m2o(SUPPLIER_CONTACT_PREFIX, 'from'),
    'email_from':
    mapper.val('from'),
    'subject':
    mapper.val('subject'),
    'body':
    mapper.val('body'),
    'date':
    mapper.val('Date',
               postprocess=lambda x: datetime.strptime(x, "%d/%m/%y %H:%M:%S").
               strftime("%Y-%m-%d %H:%M:%S")),
}

#Step 4: Process data
processor.process(mapping, 'data/mail.message.csv', {})