I use python-docx to parse docx file, then use xmlrpc to write content to odoo res.partner. Here is my code:
# -*- coding: utf-8 -*-
from os import listdir
from os.path import isfile, join
from docx import Document
import xmlrpclib
username = 'admin' #the user
pwd = 'password' #the password of the user
dbname = 'odoo8_win' #the database
# OpenERP Common login Service proxy object
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
#replace localhost with the address of the server
# OpenERP Object manipulation service
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
mypath="D:\py_test_files"
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
#open doc
for file in onlyfiles:
cv_name = mypath + '\\' + file
name = file
document = Document(cv_name)
l = [ paragraph.text.encode('utf-8') for paragraph in document.paragraphs];
for i in l:
cv = u"".join(i.decode('utf-8'))
print cv # correct without problems
partner = {
'name': name,
'cv': cv,
}
#calling remote ORM create method to create a record
partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner)
cv sample:
Education
National University Of Singapore Bachelor Of Business Administration
There is no error when run this python, when I login in odoo to check the field, only can see last paragraph:
National University Of Singapore Bachelor Of Business Administration
May I ask help how to sove this problem?