Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Stucked with "creating or updating database tables" in the log

By
Sebastian782
on 6/13/16, 12:21 PM 356 views

I am developping a custom app, i tried to install the last version of my app on my AWS odoo V8 and now odoo return error 500.

In the log i have this, and this is a continue flow:

2016-06-13 15:58:09,472 25917 INFO toto openerp.modules.module: module toto: creating or updating database tables
2016-06-13 15:58:21,888 25917 INFO toto openerp.modules.loading: loading 1 modules...
2016-06-13 15:58:22,124 25917 INFO toto openerp.modules.loading: 1 modules loaded in 0.24s, 0 queries
2016-06-13 15:58:22,175 25917 INFO toto openerp.modules.loading: loading 79 modules...
2016-06-13 15:58:24,309 25917 INFO toto openerp.modules.module: module toto: creating or updating database tables

When i try to make a backup of my databse i got this error in the log:

2016-06-13 14:01:21,625 25092 ERROR toto openerp.sql_db: bad query: ALTER TABLE "pb_orders_products" ADD FOREIGN KEY ("order_id") REFERENCES "sale_order" ON DELETE set null
Traceback (most recent call last):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
IntegrityError: insert or update on table "pb_orders_products" violates foreign key constraint "pb_orders_products_order_id_fkey"
DETAIL: Key (order_id)=(415) is not present in table "sale_order".
2016-06-13 14:01:21,626 25092 ERROR toto openerp.http: insert or update on table "pb_orders_products" violates foreign key constraint "pb_orders_products_order_id_fkey"
DETAIL: Key (order_id)=(415) is not present in table "sale_order".
Traceback (most recent call last):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 108, in dispatch_rpc
result = dispatch(method, params)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/db.py", line 70, in dispatch
return fn(*params)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/db.py", line 176, in exp_dump
dump_db(db_name, t)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/db.py", line 169, in wrapper
return func(*args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/db.py", line 184, in dump_db
registry = openerp.modules.registry.RegistryManager.get(db)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 310, in get
update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 341, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 354, in load_modules
force, status, report, loaded_modules, update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 263, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 163, in load_module_graph
init_module_models(cr, package.name, models)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/module.py", line 290, in init_module_models
obj._auto_end(cr, {'module': module_name})
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 2694, in _auto_end
cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (t, k, r, d))
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/sql_db.py", line 158, in wrapper
return f(self, *args, **kwargs)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
IntegrityError: insert or update on table "pb_orders_products" violates foreign key constraint "pb_orders_products_order_id_fkey"
DETAIL: Key (order_id)=(415) is not present in table "sale_order".

Great i know where problem come from, but i don't know how to resolve it.

I edited my __openerp__.py to comment views.

I edited my toto.py and removed everything.

Restarted the odoo server.

Nothing changed, still error 500, so if someone can help me :)

1

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 6/13/16, 12:29 PM

psql toto -c 'delete from pb_orders_products where order_id not in (select id from sale_order)'


Your table contains references to sale_order which doesn't exists anymore.

So you constraint cannot be apply ! 

Jeremy, it is my production instance, i cannot empty table.

Sebastian782
on 6/13/16, 12:34 PM

Ok, sorry i did not really read your SQL

Sebastian782
on 6/13/16, 12:37 PM

Sorry, you read right :) I have update my request to be soft :)

Jérémy Kersten (jke)
on 6/13/16, 12:38 PM

If it's production, start to try it on a backup/duplicate db :) (my mind)

Jérémy Kersten (jke)
on 6/13/16, 12:40 PM

No record deleted, I have this answer when i execute the query:

ERROR: null value in column "product_id" violates not-null constraint

DETAIL: Failing row contains (2, received, 1, 2016-01-29 09:15:05.978488, null, 1, 2016-01-29 09:15:05.978488, 2016-01-29, 2016-06-13 10:48:33.141207).

CONTEXT: SQL statement "UPDATE ONLY "public"."pb_orders_products_history" SET "product_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "product_id""

Sebastian782
on 6/13/16, 12:48 PM

Ok, reply to myself, i have to delete records into pb_orders_products_history first

Sebastian782
on 6/13/16, 12:49 PM

Thanks!!! Merci jeremy je supporterais les diable rouge ce soir ;)

Sebastian782
on 6/13/16, 12:57 PM

lol, thank you :) have a nice evening before a good Belgium beer ...

Jérémy Kersten (jke)
on 6/13/16, 1:08 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/13/16, 12:21 PM
Seen: 356 times
Last updated: 6/13/16, 12:56 PM