Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

[SOLVED] [Odoo 10] Working script under Python always raise IndexError under Odoo

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythonpostgresqlindexerrorlistodoo10
6 Respostes
8108 Vistes
Avatar
FEDERICO LEONI

I have a little piece of one of my scripts that works perfectly fine on Python but always raise an IndexError under Odoo:

for nt in newTable:
    (the next line is obviously an extract of the newTable list)
nt = [21562, 7161, 'Cotto GR', '+ Muss. Vegetal', Decimal('1.0'), 'Mesa 05', 'A fazer', 'N', '0', datetime.datetime(2017, 2, 9, 10, 57, 27)]
items in list = 10
    self.env.cr.execute(sql_write_ord, (nt)) 
    self.env.cr.commit()

In python the syntax works fine, the nt list contains 10 items, as asked by the INSERT INTO sql call, but in odoo I get:

File "/odoo_test2/odoo_test2-server/addons/divina_v10/models/divina_pos_V10.py", line 111, in _compute_kot_lines self.env.cr.execute(sql_write_ord, (nt)) File "/odoo_test2/odoo_test2-server/odoo/sql_db.py", line 141, in wrapper return f(self, *args, **kwargs) File "/odoo_test2/odoo_test2-server/odoo/sql_db.py", line 218, in execute res = self._obj.execute(query, params)IndexError: tuple index out of range

For now I've tested with:

self.env.cr.execute(sql_write_ord, [nt[0], nt[1], nt[2], nt[3], nt[4], nt[5], nt[6], nt[7], nt[8], nt[9]])

and

self.env.cr.execute(sql_write_ord, ([tuple(nt)]))

but raise the same error.

Solved:

There are many logs on my code and I found the error of tuple index out of range is generated by the first tuple in newTable, This issue is not present under Python. To solve the problem I was obliged to flush newTable before starting to populate it, because the first list is created (and I still don't know why since in Python is fine) with just 7 items out of 10, then generate the error.  

0
Avatar
Descartar
Avatar
FEDERICO LEONI
Autor Best Answer

There are many logs on my code and I found the error of tuple index out of range is generated by the first tuple in newTable, This issue is not present under Python. To solve the problem I was obliged to flush newTable before starting to populate it, because the first list is created (and I still don't know why since in Python is fine) with just 7 items out of 10, then generate the error.

0
Avatar
Descartar
Avatar
Hilar Andikkadavath
Best Answer

Hi,

please try self.env.cr.execute(sql_write_ord, ([tuple(nt)]))

0
Avatar
Descartar
FEDERICO LEONI
Autor

Hi Hilar,

I've already tried with ([tuple(nt)]), it will not working on Python.

I've tried with single items too:

(sql_write_ord, [nt[0], nt[1], nt[2], nt[3], nt[4], nt[5], nt[6], nt[7], nt[8], nt[9]])

that solution it's working on Python but not on Odoo.

Again why Odoo can't read my list of lists?

Hilar Andikkadavath

Try this syntax then,

cr.execute(""" INSERT INTO %s(name, lang, res_id, src, type, value, module, state, comments)

SELECT name, lang, res_id, src, type, value, module, state, comments

FROM %s AS ti

WHERE NOT EXISTS(SELECT 1 FROM ONLY %s AS irt WHERE %s);

""" % (self._model_table, self._table, self._model_table, find_expr))

Please check here how the values are given and try to add your values as per this syntax

FEDERICO LEONI
Autor

Hilar, thanks to have drive my mind where the error is.

Seems Odoo is jumping some passages on my script.

I'va added a series of logs and I can clearly see that the list is not populated correctly. Again this is part of a large script i run as a daemon that works perfectly fine under Python (since 2015) and Odoo 8 / 9 / 10.

I need to look elsewhere, probably there is something bothering Oddo where my list is created.

FEDERICO LEONI
Autor

Solved with a second round of flush before starting to populate the list. Kind of weird, but it's working.

Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
Error in General settings
python postgresql erp odoo10
Avatar
0
de jul. 17
4412
modulo no crea tabla en postgresql odoo 17
python postgresql
Avatar
Avatar
Avatar
2
de maig 24
2320
How to migrate data from Odoo 10 enterprise with PostgreSQL 9.5 to PostgreSQL 12?
postgresql odoo10
Avatar
Avatar
1
de nov. 23
3283
error ConfigParser.ParsingError: File contains parsing errors
python odoo10
Avatar
0
de març 21
7605
how to pass parameters using with_context ? Solved
python odoo10
Avatar
Avatar
3
de jul. 20
22250
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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