-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathblog_tag.py
39 lines (28 loc) · 1.47 KB
/
blog_tag.py
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
#!/usr/bin/python
# encoding: utf-8
import xmlrpclib
usernameFrom = 'admin' # Odoo From user
pwdFrom = 'admin' # Odoo From password
dbFrom = 'odoo' # Odoo From base de datos
urlFrom = 'http://localhost:8069' # Odoo From URL
usernameTo = 'admin' # Odoo To user
pwdTo = 'admin' # Odoo To password
dbTo = 'odoo' # Odoo To base de datos
urlTo = 'http://localhost:8069' # Odoo To URL
model = 'blog.tag' # Modelo de Odoo a migrar
valsFrom = {'fields': ['name']}
commonFrom = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(urlFrom))
commonFrom.version()
uidFrom = commonFrom.authenticate(dbFrom, usernameFrom, pwdFrom, {})
commonTo = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(urlTo))
commonTo.version()
uidTo = commonTo.authenticate(dbTo, usernameTo, pwdTo, {})
modelsFrom = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(urlFrom))
modelsTo = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(urlTo))
ids_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, model, 'search', [[]], {'order': 'id asc'}) # Ajustar dominio de búsqueda de acuerdo a las necesidades
print(ids_from)
for id_from in ids_from:
from_id = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, model, 'read', [id_from], valsFrom)
to_id = modelsTo.execute_kw(dbTo, uidTo, pwdTo, model, 'create', [{
'name': from_id[0]['name'],
}])