Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Error in odoo 12 after restoring database, ProgrammingError: relation "ir_attachment_id_seq" does not exist

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
databasebackuprestorerestoredbodoo12
6 Replies
9846 Rodiniai
Portretas
José Luis Benitez

Hi, I got this error in odoo 12 after importing a database from a computer to another:

psycopg2.ProgrammingError: relation «ir_attachment_id_seq» does not exist
LINE 1: ...res_model", "type", "website_id") VALUES (nextval('ir_attach...
^
Error to render compiling AST
ProgrammingError: no existe la relación «ir_attachment_id_seq»
LINE 1: ...res_model", "type", "website_id") VALUES (nextval('ir_attach...
^
Template: website.layout
Path: /templates/t/t/t[5]/t[6]
Node:


------ SOLUTION --------


The error was because the original database was Postgres 10 but my local database is Postgres 9.6, the dump.sql file in the .zip file contains "to integer" in the script and Postgres 9.X doesn't support this operation.

To fix this error you need decompress the .zip file and edit the dump.sql deleting all the "to integer", after deleting all ocurrence compress all the files again and restore the backup.

If your dump.sql file is larger than 500 MB I recomend using a terminal text like nano or vim in linux to replace all the "as integer" ocurrencies to avoid overflowing your RAM memory



0
Portretas
Atmesti
Portretas
Pranav P S
Best Answer
  • Apparently there is a single statement that causes this when creating sequences, which is the "AS INTEGER" in every "CREATE SEQUENCE" which is not supported in PostgreSQL 9.6. To work around this, you need to unzip your backup file, open & edit your dump.sql file and delete every occurrence of "AS INTEGER" from every "CREATE SEQUENCE" statement. Then zip the contents again and try to restore one more time. It will work.

(Refered from stackoverflow)


1
Portretas
Atmesti
Portretas
Alexander Hilsum
Best Answer

This will do the job. Run in PGADMIN or commandline
remove -- to execute

DO $$
DECLARE
_record RECORD;
_max BIGINT;
_exec VARCHAR;

BEGIN

FOR _record IN
(
SELECT table_schema,
*
FROM information_schema.COLUMNS
WHERE column_name = 'id' and table_name != 'xxx')
LOOP
execute format('select max(id) from %s', _record.table_name) into _max;

IF _max is NULL THEN
_max = 1;
ELSE
_max = _max + 10;
END IF;

_exec = 'CREATE SEQUENCE IF NOT EXISTS ' || _record.table_name || '_id_seq START ' || _max;
RAISE INFO '%', _exec;

execute _exec;



END LOOP;
END;
$$ ;


1
Portretas
Atmesti
Portretas
Forcix BV
Best Answer

@Alexander Hilsum: Thanks a lot for your fix script. It helped me fix my DB with 50 missing indices in no time. I did add two lines to configure the sequence as default nextval on the column:


DO $$

DECLARE

_record RECORD;

_max BIGINT;

_exec VARCHAR;

_exec2 VARCHAR;


BEGIN


FOR _record IN

(

SELECT table_schema,

*

FROM information_schema.COLUMNS

WHERE column_name = 'id' and table_name != 'xxx')

LOOP

execute format('select max(id) from %s', _record.table_name) into _max;


IF _max is NULL THEN

_max = 1;

ELSE

_max = _max + 10;

END IF;


_exec = 'CREATE SEQUENCE IF NOT EXISTS ' || _record.table_name || '_id_seq START ' || _max;

RAISE INFO '%', _exec;


execute _exec;

_exec2 = 'alter table ' || _record.table_name || ' alter column id set default nextval(''' || _record.table_name || '_id_seq''::regclass)';

RAISE INFO '%', _exec2;

execute _exec2;


END LOOP;

END;

$$ ;

0
Portretas
Atmesti
Portretas
ASOP
Best Answer

This Solve:

CREATE SEQUENCE ir_attachment_id_seq START 1;

then 

SELECT setval('ir_attachment_id_seq', (SELECT MAX(id) FROM ir_attachment));

0
Portretas
Atmesti
Portretas
Oliver Breeden
Best Answer

I had a similar issue on a custom table that I had changed the name of.

The fix was to recreate the sequence in the database (through pgadmin or other database management tool)

My table was called 'sale_partexchange' so you can just replace the table name with your one and run the following SQL statement.

DROP SEQUENCE IF EXISTS sale_partexchange_id_seq;
CREATE SEQUENCE sale_partexchange_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;


0
Portretas
Atmesti
Portretas
nando
Best Answer

im having a pretty weird problem as well, when i try to go into "Technical -> sequencing" in order to change the sequence number of my invoices, i get inmediatly a server error, where it says

Traceback (most recent call last):
  File "/odoo/odoo-server/odoo/api.py", line 1039, in get
    value = self._data[key][field][record._ids[0]]
KeyError: 254

so i cannot change the invoice sequences, at the same time, checking the history of invoices, the sequence never changed the year from 2021, it stuck, right now begginning 2023, we have inv/2021/0001

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Icons Doesn't Show After Restoring Database Solved
database backup restore restoredb databasebackup
Portretas
Portretas
1
kov. 24
9078
how to restore database for different versions of Odoo? Solved
database backup restore restoredb odoo
Portretas
Portretas
1
rugp. 15
7716
Restore completes but database not visible Solved
backup restore restoredb
Portretas
Portretas
Portretas
3
saus. 22
5880
Odoo 12 One app free Cloud Hosting Database Restore Problem
database backup restore
Portretas
Portretas
Portretas
2
rugs. 19
4325
Error message in restoring database via both zip file and dump file for Odoo 8 Solved
database backup restore
Portretas
Portretas
3
birž. 16
16153
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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