New units of measure reference old ones that have been deleted

Bug #1025819 reported by Don Kirkby
6
This bug affects 1 person
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:OpenUpgrade:product: loading migrations/6.0.1.1/data.xml
[...] ERROR:db.cursor:bad query: insert into "product_uom" (id,"uom_type","rounding","active","factor",create_uid,create_date) values (10,'reference','0.01','True',1.0,1,now())
Traceback (most recent call last):
  File "[...]/server/upgrade-6.0/bin/sql_db.py", line 131, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "category_id" violates not-null constraint

[...] ERROR:tools.convert.xml_import:Parse error in [...]/addons/upgrade-6.0/product/migrations/6.0.1.1/data.xml:19:
<record id="product_uom_kgm" model="product.uom">
            <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-addons-6.0 --config ~/openerp-server.config

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

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.