update pretty xml

This commit is contained in:
bcomsugi 2023-11-13 13:19:48 +07:00
parent f3b1cac25b
commit 2df3be79cc
2 changed files with 10 additions and 2 deletions

View File

@ -198,7 +198,6 @@ class SalesOrderQuery:
# if soidx == len(self.SalesOrderList)-1: #last list then set the'400_Sales_discount'
# print(f'disc_amount:{format(disc_amount, ".2f")}')
# if disc_amount != 0:
# # disc_amount=format(disc_amount, ".2f")
# InvoiceLineAdd = self.create_sub_element(ET, InvoiceAdd, "InvoiceLineAdd", "\n ", 10 )
# ItemRef = self.create_sub_element(ET, InvoiceLineAdd, "ItemRef", "\n ", 12)
@ -219,7 +218,16 @@ class SalesOrderQuery:
qbxml_query = qbxml_query + "\n" + mydata
# print(f'create_invoiceadd_QBXML->Create_Invoiceadd_QBXML: {qbxml_query}')
# print(f"replyfrom qbxml:{self.connect_to_quickbooks(qbxml_query)}")
# print([s for s in qbxml_query.split('\n') if s.strip(' ') != ''])
import xml.dom.minidom
# dom = xml.dom.minidom.parse(xml_fname) # or
dom = xml.dom.minidom.parseString(qbxml_query)
pretty_xml_as_string = dom.toprettyxml(" ").split('\n')
# pretty_xml_as_string = '\n'.join([s for s in pretty_xml_as_string if s.strip(' ') != ""])
pretty_xml_as_string = '\n'.join([s for s in pretty_xml_as_string if s.strip() ])
print(pretty_xml_as_string)
return qbxml_query

View File

@ -105,7 +105,7 @@ def show_inv(request):
if itu:
invoiceaddQBXML=ini.create_invoiceadd_QBXML()
print(invoiceaddQBXML)
print(ini.connect_to_quickbooks(ini.create_invoiceadd_QBXML()))
# print(ini.connect_to_quickbooks(ini.create_invoiceadd_QBXML()))
return render( request, "Invoice/so_list_form.html", context)
# return HttpResponse('')