Merge lp:~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep into lp:~product-core-editors/openerp-product-attributes/7.0

Proposed by Leonardo Pistone
Status: Merged
Merged at revision: 229
Proposed branch: lp:~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep
Merge into: lp:~product-core-editors/openerp-product-attributes/7.0
Diff against target: 24 lines (+9/-8)
1 file modified
product_custom_attributes/migrations/7.0.0.2/post-migration.py (+9/-8)
To merge this branch: bzr merge lp:~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+198592@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM
Thanks

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product_custom_attributes/migrations/7.0.0.2/post-migration.py'
2--- product_custom_attributes/migrations/7.0.0.2/post-migration.py 2013-09-30 11:21:33 +0000
3+++ product_custom_attributes/migrations/7.0.0.2/post-migration.py 2013-12-11 15:53:04 +0000
4@@ -25,11 +25,12 @@
5
6
7 def migrate(cr, version):
8- logger.info("Migrating product_custom_attributes from version %s", version)
9- cr.execute("UPDATE product_template pt "
10- "SET attribute_set_id = (SELECT pp.attribute_set_id "
11- " FROM product_product pp WHERE "
12- " pp.product_tmpl_id = pt.id "
13- " LIMIT 1)"
14- "WHERE pt.attribute_set_id IS NULL")
15- cr.execute('ALTER TABLE product_product DROP COLUMN attribute_set_id')
16+ if version: # do not run on a fresh DB, see lp:1259975
17+ logger.info("Migrating product_custom_attributes from version %s", version)
18+ cr.execute("UPDATE product_template pt "
19+ "SET attribute_set_id = (SELECT pp.attribute_set_id "
20+ " FROM product_product pp WHERE "
21+ " pp.product_tmpl_id = pt.id "
22+ " LIMIT 1)"
23+ "WHERE pt.attribute_set_id IS NULL")
24+ cr.execute('ALTER TABLE product_product DROP COLUMN attribute_set_id')

Subscribers

People subscribed via source and target branches