This question has been flagged
6 Replies
5727 Views

Hi,

I'm trying to install inventory module on odoo 9 but there is an error when I clic on install:

Odoo Warning - Validation ErrorThe operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it- creation/update: a mandatory field is not correctly set[object with reference: stock_picking - stock.picking]

Then I can just clic on Cancel install.

Here is part of postgres serveur log file:

2016-11-14 23:11:48 CET [31598-1] odoo@odoo2 ERROR: column "name" contains null values2016-11-14 23:11:48 CET [31598-2] odoo@odoo2 STATEMENT: ALTER TABLE "stock_location" ALTER COLUMN "name" SET NOT NULL2016-11-14 23:11:48 CET [31598-3] odoo@odoo2 ERROR: column "name" contains null values2016-11-14 23:11:48 CET [31598-4] odoo@odoo2 STATEMENT: ALTER TABLE "stock_location_route" ALTER COLUMN "name" SET NOT NULL2016-11-14 23:11:49 CET [31598-5] odoo@odoo2 ERROR: column "product_uom" contains null values2016-11-14 23:11:49 CET [31598-6] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ALTER COLUMN "product_uom" SET NOT NULL2016-11-14 23:11:49 CET [31598-7] odoo@odoo2 ERROR: column "location_id" contains null values2016-11-14 23:11:49 CET [31598-8] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ALTER COLUMN "location_id" SET NOT NULL2016-11-14 23:11:49 CET [31598-9] odoo@odoo2 ERROR: column "name" contains null values2016-11-14 23:11:49 CET [31598-10] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ALTER COLUMN "name" SET NOT NULL2016-11-14 23:11:49 CET [31598-11] odoo@odoo2 ERROR: column "location_dest_id" contains null values2016-11-14 23:11:49 CET [31598-12] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ALTER COLUMN "location_dest_id" SET NOT NULL2016-11-14 23:11:49 CET [31598-13] odoo@odoo2 ERROR: column "product_id" contains null values2016-11-14 23:11:49 CET [31598-14] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ALTER COLUMN "product_id" SET NOT NULL2016-11-14 23:11:49 CET [31598-15] odoo@odoo2 ERROR: column "location_id" contains null values2016-11-14 23:11:49 CET [31598-16] odoo@odoo2 STATEMENT: ALTER TABLE "stock_pack_operation" ALTER COLUMN "location_id" SET NOT NULL2016-11-14 23:11:49 CET [31598-17] odoo@odoo2 ERROR: column "location_dest_id" contains null values2016-11-14 23:11:49 CET [31598-18] odoo@odoo2 STATEMENT: ALTER TABLE "stock_pack_operation" ALTER COLUMN "location_dest_id" SET NOT NULL2016-11-14 23:11:50 CET [31598-19] odoo@odoo2 ERROR: insert or update on table "stock_move" violates foreign key constraint "stock_move_picking_id_fkey"2016-11-14 23:11:50 CET [31598-20] odoo@odoo2 DETAIL: Key (picking_id)=(3) is not present in table "stock_picking". 2016-11-14 23:11:50 CET [31598-21] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ADD FOREIGN KEY ("picking_id") REFERENCES "stock_picking" ON DELETE set null

Here is odoo log file for this:

2016-11-14 22:11:48,501 22714 INFO odoo2 openerp.modules.loading: loading 1 modules... 2016-11-14 22:11:48,511 22714 INFO odoo2 openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries2016-11-14 22:11:48,574 22714 INFO odoo2 openerp.modules.loading: loading 46 modules... 2016-11-14 22:11:48,614 22714 INFO odoo2 openerp.modules.loading: 46 modules loaded in 0.04s, 0 queries2016-11-14 22:11:48,619 22714 ERROR odoo2 openerp.modules.graph: module sale_mrp: Unmet dependencies: mrp2016-11-14 22:11:48,619 22714 WARNING odoo2 openerp.modules.graph: Some modules were not loaded. 2016-11-14 22:11:48,620 22714 INFO odoo2 openerp.modules.loading: loading 51 modules... 2016-11-14 22:11:48,791 22714 INFO odoo2 openerp.modules.module: module stock: creating or updating database tables2016-11-14 22:11:48,860 22714 WARNING odoo2 openerp.models.schema: Table 'stock_location': unable to set a NOT NULL constraint on column 'name' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_location ALTER COLUMN name SET NOT NULL2016-11-14 22:11:48,896 22714 WARNING odoo2 openerp.models.schema: Table 'stock_location_route': unable to set a NOT NULL constraint on column 'name' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_location_route ALTER COLUMN name SET NOT NULL2016-11-14 22:11:49,024 22714 WARNING odoo2 openerp.models.schema: Table 'stock_move': unable to set a NOT NULL constraint on column 'product_uom' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_move ALTER COLUMN product_uom SET NOT NULL2016-11-14 22:11:49,037 22714 WARNING odoo2 openerp.models.schema: Table 'stock_move': unable to set a NOT NULL constraint on column 'location_id' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_move ALTER COLUMN location_id SET NOT NULL2016-11-14 22:11:49,074 22714 WARNING odoo2 openerp.models.schema: Table 'stock_move': unable to set a NOT NULL constraint on column 'name' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_move ALTER COLUMN name SET NOT NULL2016-11-14 22:11:49,080 22714 WARNING odoo2 openerp.models.schema: Table 'stock_move': unable to set a NOT NULL constraint on column 'location_dest_id' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_move ALTER COLUMN location_dest_id SET NOT NULL2016-11-14 22:11:49,085 22714 WARNING odoo2 openerp.models.schema: Table 'stock_move': unable to set a NOT NULL constraint on column 'product_id' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_move ALTER COLUMN product_id SET NOT NULL2016-11-14 22:11:49,310 22714 WARNING odoo2 openerp.models.schema: Table 'stock_pack_operation': unable to set a NOT NULL constraint on column 'location_id' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_pack_operation ALTER COLUMN location_id SET NOT NULL2016-11-14 22:11:49,322 22714 WARNING odoo2 openerp.models.schema: Table 'stock_pack_operation': unable to set a NOT NULL constraint on column 'location_dest_id' ! If you want to have it, you should update the records and execute manually: ALTER TABLE stock_pack_operation ALTER COLUMN location_dest_id SET NOT NULL2016-11-14 22:11:50,149 22714 INFO odoo2 openerp.sql_db: bad query: ALTER TABLE "stock_move" ADD FOREIGN KEY ("picking_id") REFERENCES "stock_picking" ON DELETE set null

2016-11-14 22:11:50,150 22714 ERROR odoo2 openerp.modules.registry: Failed to load registryTraceback (most recent call last): File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 386, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 338, in load_modules loaded_modules, update_module) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 237, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 137, in load_module_graph init_module_models(cr, package.name, models) File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 307, in init_module_models obj._auto_end(cr, {'module': module_name}) File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 250, in wrapper return old_api(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 2716, in _auto_end cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (t, k, r, d)) File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 141, in wrapper return f(self, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 220, in execute res = self._obj.execute(query, params)IntegrityError: insert or update on table "stock_move" violates foreign key constraint "stock_move_picking_id_fkey"DETAIL: Key (picking_id)=(3) is not present in table "stock_picking". 2016-11-14 22:11:50,155 22714 INFO odoo2 openerp.modules.loading: loading 1 modules... 2016-11-14 22:11:50,167 22714 INFO odoo2 openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries2016-11-14 22:11:50,194 22714 INFO odoo2 openerp.modules.loading: loading 46 modules... 2016-11-14 22:11:50,238 22714 INFO odoo2 openerp.modules.loading: 46 modules loaded in 0.04s, 0 queries2016-11-14 22:11:50,736 22714 INFO odoo2 openerp.modules.loading: Modules loaded.

I've already tried to duplicate database: same issue

I try to create new database and I can install inventory module on it but I need to install module on first database that contains datas.

What can I do ? Thanks for help.

Avatar
Discard

Hi, thanks for answering.

This is fresh install, we start from odoo 9, maybe some modules were installed incorrectly. I've checked differences between both databases and I can see that some tables are missing on database that contains datas.

We have executed manually all of (correct) ALTER TABLE indicated into the log file and now the persistent error stays:

2016-11-15 15:38:18 CET [31598-42] odoo@odoo2 ERROR: insert or update on table "stock_move" violates foreign key constraint "stock_move_location_dest_id_fkey"2016-11-15 15:38:18 CET [31598-43] odoo@odoo2 DETAIL: Key (location_dest_id)=(0) is not present in table "stock_location". 2016-11-15 15:38:18 CET [31598-44] odoo@odoo2 STATEMENT: ALTER TABLE "stock_move" ADD FOREIGN KEY ("location_dest_id") REFERENCES "stock_location" ON DELETE set null

Is there a way to reinstall odoo without loosing datas ? I'd like to avoid to reinstall everything and begin from scratch again ...

Thanks

Do make a backup before you install modules, especially if you are not sure about the quality and compatibility of such modules. You should definitely go for a clean install with loosing your data.

Best Answer

I had same problem. In my case it stated:

2019-01-10 08:12:25,649 1528 ERROR odoo odoo.sql_db: bad query: b'ALTER TABLE "stock_picking" ADD FOREIGN KEY ("location_id") REFERENCES "stock_location"("id") ON DELETE set null'
ERROR: insert or update on table "stock_picking" violates foreign key constraint "stock_picking_location_id_fkey"
DETAIL:  Key (location_id)=(12) is not present in table "stock_location".

I noticed there was no table "stock_location" at all as well as any other table starting with "stock_". Only table I saw was "stock_picking". So I removed this table assuming it would be created during installation of the module. And that's exactly what's happened. The table "stock_picking" as well as other "stock_*" ones were created and Inventory module was installed successfully.

So I'd recommend to remove all "stock_*" tables from the database and try to install Inventory module again

Avatar
Discard
Author Best Answer

Hi Patrick,

We didn't find any solution, we had to create a new database and configure again. To avoid new problem, I made a backup before each module installation to be able to rollback if needed. Sorry ...

Avatar
Discard
Best Answer

Hi Giles, did you ever find a solution? I'm having the same issue. Thanks.

Avatar
Discard
Best Answer

Hello Gilles,

maybe the error came from an other module you did try to install before but you did not cancell installation, and is not compatible with the version of odoo you are using.


Avatar
Discard