Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Artificial Intelligence
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Property Management
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Help on designing XML file with lxml

Odoberať

Get notified when there's activity on this post

This question has been flagged
xmlodoo12.0lxml
4666 Zobrazenia
Avatar
Paulo Matos

Dear all,

Good day.

I am building an xml file using lxml on Odoo12.
On the final result, I get all data on the same lines, like:

<AuditFile xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01"><Header xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01"><AuditFileVersion>1.01_01</AuditFileVersion><CompanyID>REG102.2548</CompanyID><TaxRegistrationNumber>1234567890</TaxRegistrationNumber><TaxAccountingBasis>F</TaxAccountingBasis><CompanyName>My Company</CompanyName><BusinessName> </BusinessName><CompanyAddress><BuildingNumber> </BuildingNumber><StreetName>Endreço da empresa</StreetName><City>Setubal</City><PostalCode> </PostalCode><Country>PT</Country></CompanyAddress>
<FiscalYear>2019</FiscalYear><StartDate>2019-10-20</StartDate><EndDate>2019-10-20</EndDate><CurrencyCode>PT</CurrencyCode><DateCreated>2019-10-20</DateCreated><TaxEntity>Global</TaxEntity><ProductCompanyTaxID>507477758</ProductCompanyTaxID><SoftwareValidationNumber>0</SoftwareValidationNumber><ProductID>Odoo</ProductID><ProductVersion>12</ProductVersion><HeaderComment>Odoo - OpenSource #1</HeaderComment><Telephone> </Telephone><Fax> </Fax><Email>info@yourcompany.com</Email><Website>http://www.yourcompany.com</Website></Header>
</AuditFile>

How can I get the results on a more clear and readable format with an element per line, like:

   <AuditFile xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01">
      <Header xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.01_01">
         <AuditFileVersion>1.01_01</AuditFileVersion>
            <CompanyID>REG102.2548</CompanyID>
            <TaxRegistrationNumber>1234567890</TaxRegistrationNumber>
            <BusinessName> </BusinessName>
            <CompanyAddress>
                 <BuildingNumber> </BuildingNumber>
                 <PostalCode> </PostalCode>
                 <Country>PT</Country>
            </CompanyAddress>
            <FiscalYear>2019</FiscalYear>
            <TaxEntity>Global</TaxEntity>
            <ProductCompanyTaxID>507477758</ProductCompanyTaxID>
            <SoftwareValidationNumber>0</SoftwareValidationNumber>
            <ProductID>Odoo</ProductID>
      </Header>
    </AuditFile>

The code I am using for writing the xml is something like:

    #For the root and header element
    root = et.Element("AuditFile", attrib = attrib)
   header = et.SubElement(root, 'Header', xmlns=self.xmlns)
   header.tail = '\n'

    #For the SubElement AuditFileVersion
   et.SubElement(header, 'AuditFileVersion').text='1.01_01'

   #HEADER
   header_block = (
         ('CompanyID', CompanyID),
         ('TaxRegistrationNumber', TaxRegistrationNumber),
         ('TaxAccountingBasis', TaxAccountingBasis),
         ('CompanyName', CompanyName),
         ('BusinessName', BusinessName),
   )
   for tag, value in header_block:
      if value is None :
         continue
      et.SubElement(header, tag).text= value

   #Header | CompanyAddress
   headerCompanyAddress = et.SubElement(header, 'CompanyAddress')
   headerCompanyAddress.tail = '\n'

   header_block = (
         ('BuildingNumber', BuildingNumber),
         ('StreetName', StreetName),
         ('AddressDetail', AddressDetail),
         ('City', City),
         ('PostalCode', PostalCode),
         ('Province', Province),
         ('Country', 'AO'),
   )
   for tag, value in header_block:
      if value is None :
          continue
      et.SubElement(headerCompanyAddress, tag).text= value

...and so on!

Thank you all in advance

Best regards

PM

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to give access only for admin to edit a field in odoo12 Solved
python xml odoo12.0
Avatar
Avatar
Avatar
2
máj 25
9904
Help on passing values from dictionary computed field to report Solved
xml reporting odoo12.0
Avatar
Avatar
2
dec 19
6644
Add dates "date_range_ids" (From Date and To Date) from custom module to new sequence Solved
xml sequence odoo12.0
Avatar
Avatar
1
júl 19
8239
Display graph in one2many field odoo 12
xml graph odoo12.0
Avatar
0
okt 18
5565
Background Color depends on a field
python xml colors odoo12.0
Avatar
Avatar
1
sep 22
9414
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now