New units of measure reference old ones that have been deleted
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenUpgrade Addons |
New
|
Undecided
|
Unassigned |
Bug Description
When I try to upgrade from 5.0.16 to 6.0, I get the following error (slightly edited):
[...] INFO:OpenUpgrad
[...] ERROR:db.cursor:bad query: insert into "product_uom" (id,"uom_
Traceback (most recent call last):
File "[...]/
res = self._obj.
IntegrityError: null value in column "category_id" violates not-null constraint
[...] ERROR:tools.
<record id="product_
<field name="factor" eval="1"/>
</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 Products menu, choose Configuration: Units of Measure: Units of Measure.
5. Delete the record with code "KGM".
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:
I think the data.xml file is being processed as if the module were being installed for the first time, so it tries to insert the missing kilogram unit. However, that record in the data file was intended to update an existing record and doesn't have all the required fields, so the insert fails. This is similar to bug 1025797.
Suggested fix:
Recreate any deleted unit of measure records and mark them as inactive. I'll create a merge proposal with the code, but it requires the fix to bug 1025797 first.
Related branches
- Stefan Rijnhart (Opener): Disapprove
-
Diff: 19 lines (+9/-0)1 file modifiedproduct/migrations/6.0.1.1/pre-migration.py (+9/-0)
Hi Don,
thank you for your excellent reports and suggested solutions. We are working on a generic solution for lp:1025797 which works for this issue as well. Therefore, marking as a duplicate.
Best regards,
Stefan.