New configuration records reference old ones that have been deleted
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenUpgrade Server |
Fix Released
|
High
|
Stefan Rijnhart (Opener) |
Bug Description
When I try to upgrade from 5.0.16 to 6.0, I get the following error (slightly edited):
IntegrityError: insert or update on table "res_currency_rate" violates foreign key constraint "res_currency_
DETAIL: Key (currency_id)=(12) is not present in table "res_currency".
[...] ERROR:tools.
<record id="rateIDR1" model="
<field name="rate"
<field name="currency_id" ref="IDR"/>
<field eval="time.
</record>
Steps to reproduce:
1. Create a new database in 5.0 with no sample data and the manufacturing industry profile.
2. Set the view mode to Extended Interface.
3. Leave the default values for all the other setup steps, and set the chart of accounts to "None".
4. From the Financial Management menu, choose Configuration: Currencies.
5. Delete the record with code "IDR".
6. Run the migration using the options, "--update all --stop-after-init". The error occurs as listed above.
The full command line I use for the migration is as follows:
python openerp-server.py --database migrationtest --update all --stop-after-init --addons ~/upgrade-
Analysis:
The new import record that you see from base_data.xml references a currency with the XML id "IDR". The import process finds the ir_model_data record that matches and reads a currency id of 12. When it tries to use that id for the insert of res_currency_rate, it violates the foreign key constraint because the original currency was deleted. (Deleting the currency record doesn't delete its matching ir_model_data record in version 5.0.)
During our migration, we found similar problems on other tables: document_directory and product_uom. I'll create separate bugs for them.
Suggested fix:
Recreate any deleted configuration records and mark them as inactive. I'll create a merge proposal with the code.
Related branches
- Stefan Rijnhart (Opener): Disapprove
-
Diff: 102 lines (+81/-0)2 files modifiedbin/addons/base/migrations/6.0.1.3/pre-migration.py (+12/-0)
bin/openupgrade/openupgrade.py (+69/-0)
- Don Kirkby (community): Disapprove
- Holger Brunn (Therp): Approve
-
Diff: 23 lines (+13/-0)1 file modifiedbin/osv/orm.py (+13/-0)
description: | updated |
Changed in openupgrade-server: | |
status: | New → Confirmed |
status: | Confirmed → Fix Released |
importance: | Undecided → High |
assignee: | nobody → Stefan Rijnhart (Therp) (stefan-therp) |