|
15 | 15 |
|
16 | 16 | model = 'blog.post' # Modelo de Odoo a migrar |
17 | 17 |
|
18 | | -valsFrom = {'fields': ['blog_id', 'visits', 'name', 'subtitle', 'author_id', 'create_date', 'post_date', 'published_date', 'write_date', 'tag_ids']} |
| 18 | +valsFrom = {'fields': ['blog_id', 'visits', 'name', 'subtitle', 'author_id', 'create_date', 'post_date', 'content', 'published_date', 'write_date', 'tag_ids', 'website_meta_keywords', 'website_meta_title', 'website_meta_description']} |
19 | 19 |
|
20 | 20 | commonFrom = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(urlFrom)) |
21 | 21 | commonFrom.version() |
|
36 | 36 | blog_id_to = False |
37 | 37 | author_id_to = False |
38 | 38 | if from_id[0]['blog_id']: |
39 | | - blog_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'blog.blog', 'read', [from_id[0]['blog_id']], {'fields': 'name'}) |
40 | | - blog_id_to = modelsFrom.execute_kw(dbTo, uidTo, pwdTo, 'blog.blog', 'read', [[('name', '=', blog_id_from[0]['name'])]], {'fields': 'id'})[0]['id'] |
| 39 | + blog_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'blog.blog', 'read', [from_id[0]['blog_id'][0]], {'fields': ['name']}) |
| 40 | + blog_id_to = modelsTo.execute_kw(dbTo, uidTo, pwdTo, 'blog.blog', 'search', [[('name', '=', blog_id_from[0]['name'])]])[0] |
41 | 41 | if from_id[0]['author_id']: |
42 | | - author_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'res.partner', 'read', [from_id[0]['author_id']], {'fields': 'name'}) |
43 | | - author_id_to = modelsFrom.execute_kw(dbTo, uidTo, pwdTo, 'res.partner', 'read', [[('name', '=', author_id_from[0]['name'])]], {'fields': 'id'})[0]['id'] |
44 | | - |
| 42 | + author_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'res.partner', 'read', [from_id[0]['author_id'][0]], {'fields': ['name']}) |
| 43 | + author_id_to = modelsTo.execute_kw(dbTo, uidTo, pwdTo, 'res.partner', 'search', [[('name', '=', author_id_from[0]['name'])]])[0] |
| 44 | + |
45 | 45 | tags = [] |
46 | 46 |
|
47 | 47 | for tag_id in from_id[0]['tag_ids']: |
48 | | - tag_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'blog.tag', 'read', [tag_id], {'fields': 'name'}) |
49 | | - tag_id_to = modelsFrom.execute_kw(dbTo, uidTo, pwdTo, 'blog.tag', 'read', [[('name', '=', tag_id_from[0]['name'])]], {'fields': 'id'}) |
50 | | - tags.append(tag_id_to[0]['id']) |
| 48 | + tag_id_from = modelsFrom.execute_kw(dbFrom, uidFrom, pwdFrom, 'blog.tag', 'read', [tag_id], {'fields': ['name']}) |
| 49 | + tag_id_to = modelsTo.execute_kw(dbTo, uidTo, pwdTo, 'blog.tag', 'search', [[('name', '=', tag_id_from[0]['name'])]]) |
| 50 | + tags.append(tag_id_to[0]) |
51 | 51 |
|
52 | 52 | to_id = modelsTo.execute_kw(dbTo, uidTo, pwdTo, model, 'create', [{ |
53 | 53 | 'blog_id': blog_id_to, |
54 | 54 | 'name': from_id[0]['name'], |
| 55 | + 'content': from_id[0]['content'], |
55 | 56 | 'visits': from_id[0]['visits'], |
56 | | - 'subject': from_id[0]['subject'], |
| 57 | + 'subtitle': from_id[0]['subtitle'], |
57 | 58 | 'author_id': author_id_to, |
58 | 59 | 'create_date': from_id[0]['create_date'], |
59 | 60 | 'post_date': from_id[0]['post_date'], |
60 | 61 | 'published_date': from_id[0]['published_date'], |
61 | 62 | 'write_date': from_id[0]['write_date'], |
62 | 63 | 'is_published': True, |
63 | | - 'tag_ids': tags |
| 64 | + 'tag_ids': tags, |
| 65 | + 'website_meta_keywords': from_id[0]['website_meta_keywords'], |
| 66 | + 'website_meta_title': from_id[0]['website_meta_title'], |
| 67 | + 'website_meta_description': from_id[0]['website_meta_description'], |
64 | 68 | }]) |
0 commit comments