forked from tfrancoi/odoo_import_example
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsupplier.py
More file actions
46 lines (37 loc) · 1.54 KB
/
supplier.py
File metadata and controls
46 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- 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),
'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'})
#Step 5: Define output and import parameter
processor.write_to_file("2_supplier.sh", python_exe='', path='')
print('Supplier Done')