OpenERP 7 与第 3 方应用程序共享 XML-文件
OpenERP 7 share XML-file with 3th party application
您好,我想从第三方应用程序接收 XML 文件。我想过使用 REST,但这在 OpenERP 7 中不可用。任何其他解决方案都可以这样做。 XML 文件包含发票数据,当收到发票数据时,必须创建 account.invoice 的新记录。
通过 SFTP 共享文件夹
你是说你没有 XMLRPC
可用吗?您可以共享本地服务器文件夹(例如 sftp
),第三方应用程序可以将文件临时保留在那里。当您处理该文件时,您已经可以将其删除。
替代 XMLRPC >> JSONRPC 和控制器
也可以使用controllers,但是这里需要使用JSONRPC。也许您可以将普通 xml 文件包含到一个 JSON 字段中。
但我认为控制器只是为了 OpenERP 内部目的而构建的。检查我遇到的问题:question1,
注意:考虑到使用此解决方案,您将只需要在 OpenERP 实例中使用一个数据库。
处理XML文件
如果您想阅读 XML 文件,您可以使用 lxml
library. Check this other answer:
After building an Element instance e
from the XML, e.g. with the XML
function, or by parsing a file with something like
import xml.etree.ElementTree
e = xml.etree.ElementTree.parse('thefile.xml').getroot()
or any of the many other ways shown at ElementTree
, you just do
something like:
for atype in e.findall('type'):
print(atype.get('foobar'))
您好,我想从第三方应用程序接收 XML 文件。我想过使用 REST,但这在 OpenERP 7 中不可用。任何其他解决方案都可以这样做。 XML 文件包含发票数据,当收到发票数据时,必须创建 account.invoice 的新记录。
通过 SFTP 共享文件夹
你是说你没有 XMLRPC
可用吗?您可以共享本地服务器文件夹(例如 sftp
),第三方应用程序可以将文件临时保留在那里。当您处理该文件时,您已经可以将其删除。
替代 XMLRPC >> JSONRPC 和控制器
也可以使用controllers,但是这里需要使用JSONRPC。也许您可以将普通 xml 文件包含到一个 JSON 字段中。
但我认为控制器只是为了 OpenERP 内部目的而构建的。检查我遇到的问题:question1,
注意:考虑到使用此解决方案,您将只需要在 OpenERP 实例中使用一个数据库。
处理XML文件
如果您想阅读 XML 文件,您可以使用 lxml
library. Check this other answer:
After building an Element instance
e
from the XML, e.g. with the XML function, or by parsing a file with something likeimport xml.etree.ElementTree e = xml.etree.ElementTree.parse('thefile.xml').getroot()
or any of the many other ways shown at
ElementTree
, you just do something like:for atype in e.findall('type'): print(atype.get('foobar'))