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

how to implement python code in odoo10

Odoberať

Get notified when there's activity on this post

This question has been flagged
odoo10
2 Replies
5516 Zobrazenia
Avatar
Sarina

I have  this  code  which exports data in xml format  but I need to  implement  the  code in odoo with  download option. How can i do that?

import psycopg2

CONNECT_ARGS = 'host=localhost user=postgres password=postgres dbname=agni2'


def exportPlants(outfileName):
outfile = file(outfileName, 'w') #opens file for writing
connection = psycopg2.connect(CONNECT_ARGS)
cursor = connection.cursor()
cursor.execute("select * from tbl")
rows = cursor.fetchall()
outfile.write('<?xml version="1.0" ?>\n')
outfile.write('<mydata>\n')
for row in rows:
outfile.write(' <row>\n')
outfile.write(' <name>%s</name>\n' % row[0])
outfile.write(' <desc>%s</desc>\n' % row[1])
outfile.write(' <rating>%s</rating>\n' % row[2])
outfile.write(' </row>\n')
outfile.write('</mydata>\n')
outfile.close()




exportPlants('out6')
1
Avatar
Zrušiť
Avatar
Fatih Piristine
Best Answer

if you really need a sample code, in hurry without reading the docs, such as exporting xml format. look into part where sitemap.xml is handled. I guess from that point on, you will figure out everything.

like Zachary mentioned: don't go around the ORM.

0
Avatar
Zrušiť
Avatar
Zach Waite
Best Answer

It looks like maybe agni2 is your odoo database and you've bypassed odoo to prototype this export script using the postgres user? (odoo won't use postgres user per the install docs https://www.odoo.com/documentation/10.0/setup/install.html#id5)

Depending on your use case, you can develop a custom module and access the data using the ORM or call the web service api.  Odoo seems to frown on bypassing the ORM (https://www.odoo.com/documentation/10.0/reference/guidelines.html#do-not-bypass-the-orm) to execute SQL directly.

I'm guessing that since you're extracting all the data from the table in your query you're intending to ETL into some other system or perform interactive analysis; if that is the case then maybe just call the api (https://www.odoo.com/documentation/10.0/api_integration.html), or have a look at ERPpeek (http://erppeek.readthedocs.io/en/latest/)

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
Create schedule action For sending emails
odoo10
Avatar
Avatar
Avatar
2
júl 25
7946
How to send messages that are not shown in chatter? Solved
odoo10
Avatar
Avatar
Avatar
2
okt 25
10043
How to ORDER BY? [Odoo 10] Solved
odoo10
Avatar
Avatar
2
nov 24
30934
Dynamic domain functionality - possible to change domain of a field in another model with onchange? (Odoo 10) Solved
odoo10
Avatar
Avatar
Avatar
2
máj 24
9348
Change state of other module
odoo10
Avatar
Avatar
Avatar
Avatar
3
mar 24
9008
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