Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5084 มุมมอง

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")
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 24
3193
1
ส.ค. 23
4834
ir.values in odoo 11 แก้ไขแล้ว
6
เม.ย. 23
17068
2
ธ.ค. 22
6277
TypeError: node is undefined Kanban view แก้ไขแล้ว
1
ก.ย. 21
7744