Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
pythonpostgresqlindexerrorlistodoo10
6 Odpowiedzi
8113 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
FEDERICO LEONI
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Hilar Andikkadavath
Najlepsza odpowiedź

Hi,

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

0
Awatar
Odrzuć
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.

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Error in General settings
python postgresql erp odoo10
Awatar
0
lip 17
4413
modulo no crea tabla en postgresql odoo 17
python postgresql
Awatar
Awatar
Awatar
2
maj 24
2326
How to migrate data from Odoo 10 enterprise with PostgreSQL 9.5 to PostgreSQL 12?
postgresql odoo10
Awatar
Awatar
1
lis 23
3289
error ConfigParser.ParsingError: File contains parsing errors
python odoo10
Awatar
0
mar 21
7637
how to pass parameters using with_context ? Rozwiązane
python odoo10
Awatar
Awatar
3
lip 20
22281
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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