コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5090 ビュー

Hi,

I'm trying to generate a xml file after a form submission and I'm experience some problems with Odoo 11. Can't find the correct way to make it.

Where can I find a good example on how to make it ?

On previous versios it could be used this way:

on top:

"

from lxml import etree as et

"

in the class inside a def:

"

self.xmlns = "urn:OECD:XMLFileGenerated"
attrib={ 'xmlns': self.xmlns,
#'xmlns:xsi':"http://www.w3.org/2001/XMLSchema-instance",
#'xsi:noNamespaceSchemaLocation' : "saft-pt.xsd"
}

root = et.Element("GenFile", attrib = attrib )
header = et.SubElement(root, 'Header', xmlns=self.xmlns)
header.tail = '\n'

#master

root.append( self._get_masters(cr, uid, ids, context=context) )

"


Thank you,

Paulo

アバター
破棄

Hi Paulo,

Have you solved your problem?

I have noticed that you are working on saf-t, is it correct?

Please advise

Best regards

Paulo Matos

最善の回答

its just a simple way to make a XML file using python


import xml.etree.cElementTree as ET

root = ET.Element("root")
doc = ET.SubElement(root, "doc")

ET.SubElement(doc, "field1", name="blah").text = "some value1"
ET.SubElement(doc, "field2", name="asdfasd").text = "some vlaue2"

tree = ET.ElementTree(root)
tree.write("filename.xml")
アバター
破棄
関連投稿 返信 ビュー 活動
2
2月 24
3208
1
8月 23
4836
6
4月 23
17069
2
12月 22
6281
1
9月 21
7748