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
    • Schvalovania
    • 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
    • Estate Managament
    • 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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
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 resolve "IndexError: tuple index out of range" in sql statement inside python?

Odoberať

Get notified when there's activity on this post

This question has been flagged
insertpostgresql9.2python2.7openerp7.0select
1 Odpoveď
30882 Zobrazenia
Avatar
Anirudh Lou

Following is my code chunks that aims to get the sum of fields/columns from a certain table:


        ...
atc_code = nature = ''
_logger.info("\n\t\t\tI was called. My method name is %s"%(str('generate_student_resource_report')))
base = amount = percent = 0.00
for ewt in self.browse(cr,uid,ids,context):
old_history = stud_re_report_line_obj.search(cr, uid, [('parent_id','=',ewt.id)],context=context)
if old_history:
stud_re_report_line_obj.unlink(cr, uid, old_history,context=context)
_logger.info("\n\t\t\tDATE FROM %s\n\t\t\tDATE TO %s"%(str(date_from),str(date_to)))
cr.execute("insert into student_resource_report_line(partner_id,seq,base_amt,\
tax_amt,percent,atc_code,parent_id,\
nature,create_date,write_date)\
select es.partner_id as partner_id,\
(case when es.name like '%WC158%' then 1\
when es.name like '%WC160%' then 2\
when es.name like '%WC010%' then 3\
when es.name like '%WC140%' then 4\
else 0 end) as seq,\
sum(es.base_amount) as base_amt,\
sum(es.tax_amount) as tax_amt,\
(case when es.name like '%EWT 1%%' then '1.00'\
when es.name like '%EWT 2%%' then '2.00'\
when es.name like '%EWT 3%%' then '3.00'\
when es.name like '%EWT 4%%' then '4.00'\
when es.name like '%EWT 5%%' then '5.00'\
when es.name like '%EWT 6%%' then '6.00'\
when es.name like '%EWT 7%%' then '7.00'\
when es.name like '%EWT 8%%' then '8.00'\
when es.name like '%EWT 9%%' then '9.00'\
when es.name like '%EWT 10%%' then '10.00'\
else null end) as percen,\
(case when es.name like '%WC158%' then 'WC158'\
when es.name like '%WC160%' then 'WC160'\
when es.name like '%WC010%' then 'WC010'\
when es.name like '%WC140%' then 'WC140'\
else null end) as atc_code,\
(case when es.name like '%WC158%' then 'NOTEBOOK'\
when es.name like '%WC160%' then 'BACKPACK'\
when es.name like '%WC010%' then 'COLOR'\
when es.name like '%WC140%' then 'BOOKS' else null end) as nature,\
(now()) as create_date,(now()) as write_date,? as parent_id\
from student_resource es where es.date between ? and ? \
group by es.partner_id,es.name",(ewt.id,ewt.date_from,ewt.date_to))
line_list = cr.fetchall()
_logger.info("\n\t\t\tSource ... %s"%(str(line_list)))
list = stud_re_report_line_obj.search(cr,uid,[('parent_id','=',ewt.id)])
lines = [line.id if line.id else False for line in stud_re_report_line_obj.browse(cr,uid,list,context=context)]
value = {
"value" : {
'name' : 'Student Resource Report',
"ewt_line" : lines
}
}
return value

My problem now is that when this method is called, It produce an error. It says:

  File "/opt/openerp/server-7/openerp/sql_db.py", line 226, in execute
res = self._obj.execute(query, params)
IndexError: tuple index out of range


and it also says that my query is bad, I dont know why? Everytime i tried it directly into PgAdmin, it works fine:


2015-08-20 01:00:10,780 5697 ERROR sample_another openerp.sql_db: bad query: insert into student_resource_report_line(partner_id,seq,base_amt, tax_at,percen,atc_code, ...

Any help/suggestion/comments is highly appreciated

0
Avatar
Zrušiť
Avatar
Pawan
Best Answer

Anirudh,

Sql Insert command's syntax is:
"insert into [your_table_name](optional_your_fields) values([values_to enter in the fields])"

Here 'insert' and 'values' are the keywords and must be there, but i can t see and "values" keyword the in your statement.

Please check out your statement...

Hope it helps you....    

0
Avatar
Zrušiť
Anirudh Lou
Autor

Thank you for the reply. But as you see I am copying data from another table so I think it is not necessary to put "values" since its values will be equal to my select statement provided it meet its parameter in "insert into" statement.

Pawan

ops.... i missed that, ..... thanks for it...can u pls provide your error in detail....

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
Set 0 for a 'None' value which is inside a list Solved
list python2.7 openerp7.0
Avatar
Avatar
2
dec 19
5033
How to solve TypeError: cannot concatenate 'str' and 'int' objects? Solved
date python2.7 openerp7.0
Avatar
Avatar
Avatar
Avatar
3
aug 15
23843
How to make a dynamique _order in python ?
python2.7 openerp7.0 orderby
Avatar
Avatar
1
mar 15
7114
want asset category(employee asset) should came in drop down of asset
postgresql postgresql9.2 python2.7
Avatar
0
mar 15
4136
please explain this strange override super behaviour
python orm python2.7 openerp7.0
Avatar
0
feb 16
3697
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 ภาษาไทย 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