如何通过主ID获取库存项目



url1="http://localhost:9000"xmlBody=";1EXPORTCOLLECTIONStockItems";xmlBody+="$$系统名称:XML";xmlBody+=";StockItemMaster ID";req=requests.post(url=url1,data=xmlBody.encode('utf-8'((res=req.text.strip((.replace("&","and"(洗涤器XML=re.sub('&.+[0-9]+;','',res(打印(已擦除的XML(响应=Et.fromstring(res(url='https://dev1.mo.vc'db='训练5'username='samiullah@xmedia.in'password='samullah'common=xmlrpc.client.ServerProxy("{}/xmlrpc/2/common".format(url((uid=common.authenticate(数据库,用户名,密码,{}(models=xmlrpc.client.ServerProxy("{}/xmlrpc/2/object".format(url((对于响应中的dat.findall('./BODY/DATA/COLLECTION/STOCKTITEM'(:namei=dat.get('NAME'(打印(namei(number=数据查找('MASTERID'(.text打印(数字(打印("名称:"(打印(namei(有效载荷="quot;1.出口对象库存项目"quot+namei+"quot我需要通过主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("&amp;","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)

您可以使用以下xml通过masterID 获取库存项目

<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>CustColl</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<!-- * Static variables like scfrom,svto,svexport format will not work -->

</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="CustColl">
<TYPE>masters</TYPE>
<!-- * will fetch all fields if you want specific fields you can specify -->
<NATIVEMETHOD>*</NATIVEMETHOD>
<FILTERS>filter</FILTERS>
</COLLECTION>
<!-- You can  change filter to other than name also -->
<!--to get any Master based on name  replace $Masterid with $Name  -->
<!--Replace 1122 with Masterid you want to search -->
<SYSTEM TYPE="Formulae" NAME="filter">$Masterid=1122</SYSTEM>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>

你可以在这里获取所有xml与tally通信

我试图把所有的计数xml放在一个地方

改进:

如果您正在使用c#/VB

您可以使用TallyConnect库

使用Tally连接器API,您可以在4行代码中获得StockItem

Using TallyConnector //Importing TallyConnector Library
Using TallyConnector.Models
public Tally Ctally = new Tally(); 
StockItem Item = await Ctally.GetStockItem(ItemName);

如果您使用Python

您可以参考本指南,了解如何在python 中使用TallyConnect库

相关内容

  • 没有找到相关文章

最新更新