Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

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

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
pythonpostgresqlindexerrorlistodoo10
6 Antworten
8112 Ansichten
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
Verwerfen
Avatar
FEDERICO LEONI
Autor Beste Antwort

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
Verwerfen
Avatar
Hilar Andikkadavath
Beste Antwort

Hi,

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

0
Avatar
Verwerfen
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.

Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Error in General settings
python postgresql erp odoo10
Avatar
0
Juli 17
4413
modulo no crea tabla en postgresql odoo 17
python postgresql
Avatar
Avatar
Avatar
2
Mai 24
2326
How to migrate data from Odoo 10 enterprise with PostgreSQL 9.5 to PostgreSQL 12?
postgresql odoo10
Avatar
Avatar
1
Nov. 23
3289
error ConfigParser.ParsingError: File contains parsing errors
python odoo10
Avatar
0
März 21
7637
how to pass parameters using with_context ? Gelöst
python odoo10
Avatar
Avatar
3
Juli 20
22280
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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