Пример #1
0
    'id': mapper.m2o(SUPPLIER_PREFIX, 'Company_ID'),
    'name': mapper.val('Company_Name'),
    '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),
    'supplier': mapper.const('1'),
    'user_id': mapper.val('Account_Manager'),
}

contact_mapping = {
    'id': mapper.m2o(SUPPLIER_CONTACT_PREFIX, 'Contact Email'),
    'parent_id/id': mapper.m2o(SUPPLIER_PREFIX, 'Company_ID'),
    'email': mapper.val('Contact Email'),
    'name': mapper.concat(' ', 'Contact First Name', 'Contact Last Name'),
    'title/id': mapper.m2o(TITLE_PREFIX, 'Contact Title'),
}

title_map = {
    'id': mapper.m2o(TITLE_PREFIX, 'Contact Title'),
    'name': mapper.val('Contact Title', skip=True),
    'shortcut': mapper.val('Contact Title')
}

#Step 4: Process data
processor.process(title_map, 'data/res.partner.title.csv', {}, 'set')
processor.process(mapping, 'data/res.partner.supplier.csv',
                  {'model': 'res.partner'})
processor.process(contact_mapping, 'data/res.partner.supplier.contact.csv',
                  {'model': 'res.partner'})
Пример #2
0
# STEP 6: Attribute Value Line
line_mapping = {
    'id': mapper.m2m_id_list(ATTRIBUTE_LINE_PREFIX, *[mapper.concat_mapper_all('_', mapper.field(f), mapper.val('ref')) for f in attribute_list]),
    'product_tmpl_id/id': mapper.m2o(TEMPLATE_PREFIX, 'ref'),
    'attribute_id/id': mapper.m2m_id_list(ATTRIBUTE_PREFIX, *[mapper.field(f) for f in attribute_list]),
    'value_ids/id': mapper.m2m_id_list(ATTRIBUTE_VALUE_PREFIX, *[mapper.concat_field_value_m2m('_', f) for f in attribute_list]),
}
context['update_many2many'] = True
processor.process(line_mapping, 'data%sproduct.attribute.line.csv' % os.sep, {'worker': 3, 'batch_size': 50,
                                                                              'context': dict(context),
                                                                              'groupby': 'product_tmpl_id/id'}, m2m=True)
context.pop('update_many2many')

# STEP 7: 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'),
    'default_code': mapper.val('ref'),
    'standard_price': mapper.num('cost'),
}
processor.process(product_mapping, 'data%sproduct.product.csv' % os.sep, {'worker': 3, 'batch_size': 50,
                                                                          'groupby': 'product_tmpl_id/id',
                                                                          'context': context}, 'set')

# #Step 8: Define output and import parameter
processor.write_output()
launchfile_write(processor.file_to_write, "4_product_import.sh", python_exe='python-coverage run -a', path='../')
Пример #3
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
Пример #4
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='')
Пример #5
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='../')
Пример #6
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),
Пример #7
0
# -*- coding: utf-8 -*-
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(
        'my_import_res_partner',
        mapper.concat('_', 'name', 'Birthdate', 'phone', 'email', 'website')),
    'name':
    mapper.val('id', postprocess=lambda x: "Partner %s" % x),
    'birthdate':
    mapper.val('Birthdate',
               postprocess=lambda x: datetime.strftime(x, "%d/%m/%y").strftime(
                   "%Y-%m-%d 00:00:))")),
    'phone':
    mapper.val('phone', postprocess=lambda x: "855%s" % (int(x) * 10)),
    'email':
    mapper.val('email', postprocess=lambda x: "Email %s" % x),
    'website':
    mapper.val('website', postprocess=lambda x: "website %s" % x)
}

processor.process(
    res_partner_mapping, 'res.partner.csv', {
        'model': 'res.partner',
        'context': "{'tracking_disable': True}",
# -*- 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', {})