예제 #1
0
        '--path',
        dest='path',
        help='Image Path Prefix, default is the working directory')
    parser.add_argument('--out',
                        dest='out',
                        help='name of the result file, default out.csv',
                        default="out.csv")
    parser.add_argument(
        '-f',
        dest='fields',
        help='Fields to convert from path to base64, comma separated',
        required=True)
    args = parser.parse_args()

    file_csv = args.file
    out_csv = args.out
    path = args.path
    fields = args.fields
    if not path:
        path = os.getcwd()
    if not path.endswith(os.sep):
        path += os.sep

    processor = Processor(file_csv)
    mapping = processor.get_o2o_mapping()
    for f in fields.split(','):
        f = f.strip()
        mapping[f] = mapper.binary_map(mapper.remove_sep_mapper(f), path)
    processor.process(mapping, out_csv, {}, 'list')
    processor.write_to_file("")
예제 #2
0

def postprocess_vat(val):
    if val:
        if len(val) == 11 and val.isdigit() and int(val) > 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'),
예제 #3
0
    'Dutch': u'Dutch / Nederlands',
}

country_map = {
    'Belgique': 'base.be',
    'BE': 'base.be',
    'FR': 'base.fr',
    'U.S': 'base.us',
    'US': 'base.us',
    'NL': 'base.nl',
}

PARTNER_PREFIX = "TEST_PARTNER"

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

pprint.pprint(processor.get_o2o_mapping())

# STEP 2 : Define the mapping for every object to import
mapping = {
    'id': mapper.m2o(PARTNER_PREFIX, 'Company_ID', skip=True),
    'name': mapper.val('Company_Name', skip=True),
    'phone': mapper.val('Phone'),
    'website': mapper.val('www'),
    'street': mapper.val('address1'),
    'city': mapper.val('city'),
    'zip': mapper.val('zip code'),
    'country_id/id': mapper.map_val('country', country_map),
예제 #4
0
# -*- 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 *

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

##STEP 2 : Define the mapping for every object to import
mapping = {
    '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 = {
예제 #5
0
    'Dutch': u'Dutch / Nederlands',
}

country_map = {
    'Belgique': 'base.be',
    'BE': 'base.be',
    'FR': 'base.fr',
    'U.S': 'base.us',
    'US': 'base.us',
    'NL': 'base.nl',
}

PARTNER_PREFIX = "TEST_PARTNER"

# STEP 1 : read the needed file(s)
processor = Processor('origin%scontact.csv' % os.sep)
# Print o2o mapping
import pprint
pprint.pprint(processor.get_o2o_mapping())

# STEP 2 : Define the mapping for every object to import
mapping = {
    'id': mapper.m2o(PARTNER_PREFIX, 'Company_ID', skip=True),
    'name': mapper.val('Company_Name', skip=True),
    'phone': mapper.val('Phone'),
    'website': mapper.val('www'),
    'street': mapper.val('address1'),
    'city': mapper.val('city'),
    'zip': mapper.val('zip code'),
    'country_id/id': mapper.map_val('country', country_map),
    'company_type': mapper.const('company'),
예제 #6
0
    'Dutch' : u'Dutch / Nederlands',
}

country_map = {
    'Belgique' : 'base.be',
    'BE' : 'base.be',
    'FR' : 'base.fr',
    'U.S' : 'base.us',
    'US' : 'base.us',
    'NL' : 'base.nl',
}

PARTNER_PREFIX = "TEST_PARTNER"

#STEP 1 : read the needed file(s)
processor = Processor('origin%scontact.csv' % os.sep)
#Print o2o mapping
import pprint
pprint.pprint(processor.get_o2o_mapping())

#STEP 2 : Define the mapping for every object to import
mapping =  {
    'id' : mapper.m2o(PARTNER_PREFIX, 'Company_ID', skip=True),
    'name' : mapper.val('Company_Name', skip=True),
    'phone' : mapper.val('Phone'),
    'website' : mapper.val('www'),
    'street' : mapper.val('address1'),
    'city' : mapper.val('city'),
    'zip' : mapper.val('zip code'),
    'country_id/id' : mapper.map_val('country', country_map),
    'company_type' : mapper.const('company'),
예제 #7
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='')
예제 #8
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', {})