Skip to content

Commit f42908a

Browse files
committed
fix: blog_post
1 parent 82596e2 commit f42908a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

blog_post.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
model = 'blog.post' # Modelo de Odoo a migrar
1717

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']}
1919

2020
commonFrom = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(urlFrom))
2121
commonFrom.version()
@@ -36,29 +36,33 @@
3636
blog_id_to = False
3737
author_id_to = False
3838
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]
4141
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+
4545
tags = []
4646

4747
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])
5151

5252
to_id = modelsTo.execute_kw(dbTo, uidTo, pwdTo, model, 'create', [{
5353
'blog_id': blog_id_to,
5454
'name': from_id[0]['name'],
55+
'content': from_id[0]['content'],
5556
'visits': from_id[0]['visits'],
56-
'subject': from_id[0]['subject'],
57+
'subtitle': from_id[0]['subtitle'],
5758
'author_id': author_id_to,
5859
'create_date': from_id[0]['create_date'],
5960
'post_date': from_id[0]['post_date'],
6061
'published_date': from_id[0]['published_date'],
6162
'write_date': from_id[0]['write_date'],
6263
'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'],
6468
}])

0 commit comments

Comments
 (0)