url1 = "http://localhost:9000" xmlBody = "1EXPORTCOLLECTIONStockItems" xmlBody += "$$SysName:XML" xmlBody += "StockItemMaster ID" req = requests.post(url = url1,data=xmlBody.encode(' utf-8')) res = req.text.strip().replace("&","and") scrubbedXML = re.sub('&.+[0-9]+;', '', res) print(scrubbedXML) response = Et.fromstring(res) url='https://dev1.mo.vc' db='trainee5' username='samiullah@xmedia.in' password='samiullah' common = xmlrpc.client。 ServerProxy('{}/xmlrpc/2/common'.format(url)) uid = common.authenticate(db, username, password, {}) models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object '.format(url)) for dat in response.findall('./BODY/DATA/COLLECTION/STOCKITEM'): namei=dat.get('NAME') print(namei) number=dat.find('MASTERID').text print(number) print("Name:") print(namei) payload=""" 1 EXPORT OBJECT 库存项目 """ +namei+ """我需要通过主 ID 检索库存项目(搜索)
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
<FETCHLIST>
<FETCH>OpeningValue</FETCH>
<FETCH>OpeningRate</FETCH>
<FETCH>OpeningBalance</FETCH>
<FETCH>ClosingBalance</FETCH>
<FETCH>ClosingRate</FETCH>
<FETCH>Parent</FETCH>
<FETCH>STANDARDPRICELIST.RATE</FETCH>
</FETCHLIST>
<TDL>
<TDLMESSAGE>
<OBJECT ID="stock item name" ISINITIALIZE="Yes">
</OBJECT>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>"""
request=requests.post(url = url1, data=payload.encode('utf-8'))
response = request.text.strip().replace("&","and")
scrubbedXML = re.sub('&.+[0-9]+;','' ,response)
# print(scrubbedXML)
try:
respRoot = Et.fromstring(scrubbedXML)
except:
pass
for data in respRoot.findall('./BODY/DATA/TALLYMESSAGE/STOCKITEM'):
try:
name=data.get('NAME')
# print(name)
except UnicodeEncodeError:
name='naa'
pass
try:
closing_ba= data.find('CLOSINGBALANCE').text
closing_bal=(re.findall(r'-?\d+\.?\d*', closing_ba))
for s in closing_bal:
closing_balance=float(s)
# print(closing_balance)
except:
closing_balance=0
pass
parent=data.find('PARENT').text
# print(parent)
try:
openbal=data.find('OPENINGBALANCE').text
open_bal=(re.findall(r'-?\d+\.?\d*', openbal))
for s_o in open_bal:
opening_balance=float(s_o)
# print(opening_balance)
except:
opening_balance=0
pass
try:
openrate=data.find('OPENINGRATE').text
open_rat=(re.findall(r'-?\d+\.?\d*', openrate))
for s_or in open_rat:
opening_rate=float(s_or)