我定义了一个字段型号.py地址:
activation_date = fields.Char(string='Activation Date')
在这个字段中,我想添加一个来自SOAP api调用的响应xml的值。我正在使用元素树来解析响应xml:
response=requests.post(self.url,cert=self.cert,data=body,headers=self.headers)
element = ElementTree.fromstring(response.content.decode('utf-8'))
body_el = element.find('{schemas.xmlsoap.org/soap/envelope}Body')
getSubscriptionsResponse = body_el.find('{http://www.example.com}getSubscriptionsResponse')
activation_date_from_xml=getSubscriptionsResponse.find('{http://www.example.com}activationDate')
我想使用create方法将这个激活日期\u from \u xml添加到我的激活日期中:
record.sudo().create({
"activation_date": activation_date_from_xml.text,
})
http.request.env.cr.commit()
但我有个错误:
in parseXml
"activation_date": activation_date_from_xml.text,
AttributeError: 'NoneType' object has no attribute 'text'
信息:响应xml中activationDate元素的值为:
2017-10-27T00:00:00+00:00
如何获得这个值并使用元素树保存在我的字段中??你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐