V7->V8: IntegrityError: foreign key constraint

Asked by Vuong Pham

I'm trying to migrate from OpenERP 7 to Odoo 8. And I'm stuck at this step. Please help me to proceed. Thank you so much!

2015-03-24 18:23:20,430 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_chat
2015-03-24 18:23:24,162 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_odoo_support
2015-03-24 18:23:40,250 13916 ERROR Db_migrated openerp.sql_db: bad query: delete from ir_ui_view where id IN (345)
Traceback (most recent call last):
  File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
IntegrityError: update or delete on table "ir_ui_view" violates foreign key constraint "ir_ui_view_inherit_id_fkey" on table "ir_ui_view"
DETAIL: Key (id)=(345) is still referenced from table "ir_ui_view".

Question information

Language:
English Edit question
Status:
Answered
For:
OpenUpgrade Addons Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manuel Vazquez Acosta (mva-led) said :
#1

Try this:

1. Remove the view with id 345 in ir_ui_view in CASCADE and also remove
from ir_module_data any row with res_model='ir.ui.view' and a res_id not
found in the ir_ui_view table.

2. Update your 7.0 DB normally (with openerp and not openupgrade). This
should recreate the removed views.

3. Upgrade with OpenUpgrade.

If the error still happens report this a github.com.

Best regards,
Manuel.

Le 24/03/15 14:41, Vuong Pham a écrit :
> New question #264133 on OpenUpgrade Addons:
> https://answers.launchpad.net/openupgrade-addons/+question/264133
>
> I'm trying to migrate from OpenERP 7 to Odoo 8. And I'm stuck at this step. Please help me to proceed. Thank you so much!
>
> 2015-03-24 18:23:20,430 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_chat
> 2015-03-24 18:23:24,162 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_odoo_support
> 2015-03-24 18:23:40,250 13916 ERROR Db_migrated openerp.sql_db: bad query: delete from ir_ui_view where id IN (345)
> Traceback (most recent call last):
> File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 234, in execute
> res = self._obj.execute(query, params)
> IntegrityError: update or delete on table "ir_ui_view" violates foreign key constraint "ir_ui_view_inherit_id_fkey" on table "ir_ui_view"
> DETAIL: Key (id)=(345) is still referenced from table "ir_ui_view".
>

Revision history for this message
Manuel Vazquez Acosta (mva-led) said :
#2

I did what I suggested cause I get the same problem. So I went:

psql -d mercurio8 -c "DELETE FROM ir_ui_view where id=272 or inherit_id=272"
psql -d mercurio8 -c "DELETE FROM ir_model_data WHERE model='ir.ui.view'
AND res_id NOT IN(SELECT id FROM ir_ui_view)"

Then I ran the upgrade and it went ok.

Bests,
Manuel.

PD: Replace my ids in the first query with yours.

Le 26/03/15 12:47, Manuel Vázquez Acosta a écrit :
> Try this:
>
> 1. Remove the view with id 345 in ir_ui_view in CASCADE and also remove
> from ir_module_data any row with res_model='ir.ui.view' and a res_id not
> found in the ir_ui_view table.
>
> 2. Update your 7.0 DB normally (with openerp and not openupgrade). This
> should recreate the removed views.
>
> 3. Upgrade with OpenUpgrade.
>
>
> If the error still happens report this a github.com.
>
> Best regards,
> Manuel.
>
>
> Le 24/03/15 14:41, Vuong Pham a écrit :
>> New question #264133 on OpenUpgrade Addons:
>> https://answers.launchpad.net/openupgrade-addons/+question/264133
>>
>> I'm trying to migrate from OpenERP 7 to Odoo 8. And I'm stuck at this step. Please help me to proceed. Thank you so much!
>>
>> 2015-03-24 18:23:20,430 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_chat
>> 2015-03-24 18:23:24,162 13916 INFO Db_migrated OpenUpgrade: Selecting autoinstallable modules im_odoo_support
>> 2015-03-24 18:23:40,250 13916 ERROR Db_migrated openerp.sql_db: bad query: delete from ir_ui_view where id IN (345)
>> Traceback (most recent call last):
>> File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 234, in execute
>> res = self._obj.execute(query, params)
>> IntegrityError: update or delete on table "ir_ui_view" violates foreign key constraint "ir_ui_view_inherit_id_fkey" on table "ir_ui_view"
>> DETAIL: Key (id)=(345) is still referenced from table "ir_ui_view".
>>
>

Can you help with this problem?

Provide an answer of your own, or ask Vuong Pham for more information if necessary.

To post a message you must log in.