Skip to Content
Menu
This question has been flagged
2 Replies
10693 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 :)

Avatar
Discard
Best Answer

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 ! 

Avatar
Discard
Author

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

Author

Ok, sorry i did not really read your SQL

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

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

Author

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""

Author

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

Author

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

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