Untitled
unknown
plain_text
24 days ago
862 B
2
Indexable
Never
import xml.etree.ElementTree as Et import requests from odoo.exceptions import UserError def get_data(self, tvals): if not self.env.company.tally_url: raise UserError(_('Please Configure the Tally URL')) # Send the request to the Tally URL req = requests.post(url=self.env.company.tally_url, data=tvals) # Check the response text and clean it if necessary if req.text: xml_tags = req.text.replace('', '') # Removing unwanted characters else: xml_tags = req.text # Parse the XML response using a fresh parser try: # Create a new XML parser instance for each parsing parser = Et.XMLParser(encoding="utf-8") res = Et.fromstring(xml_tags.strip(), parser=parser) except MemoryError: raise UserError(_('Memory Error occurred while parsing XML data.')) return res
Leave a Comment