credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05568
lp:~sylvain-legal/openupgrade-server/base-res_company-migrate-logo into lp:openupgrade-server
Sylvain LE GAL (GRAP) has proposed merging lp:~sylvain-legal/openupgrade-server/base-res_company-migrate-logo into lp:openupgrade-server.
Commit message:
[ADD] migration of the logo of 'res_company'. (in V7 'res_company'.'logo' is now field related to 'res_partner'.'image')
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~sylvain-legal/openupgrade-server/base-res_company-migrate-logo/+merge/191510
Add migration script for res_company.logo.
--
https://code.launchpad.net/~sylvain-legal/openupgrade-server/base-res_company-migrate-logo/+merge/191510
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~sylvain-legal/openupgrade-server/base-res_company-migrate-logo into lp:openupgrade-server.
=== modified file 'openerp/addons/base/migrations/7.0.1.3/post-migration.py'
--- openerp/addons/base/migrations/7.0.1.3/post-migration.py 2013-09-13 20:11:15 +0000
+++ openerp/addons/base/migrations/7.0.1.3/post-migration.py 2013-10-16 21:36:14 +0000
@@ -194,6 +194,23 @@
cr, SUPERUSER_ID, currency_ids,
{'company_id': False})
+def migrate_res_company_logo(cr, pool):
+ """
+ Transfert logo from res_company to res_partner linked to the res_company,
+ according to the new behaviour of V7 :
+ 'res_company.logo' is now a field reladed to 'res_partner.image'
+ """
+ partner_obj = pool.get('res.partner')
+ cr.execute("""
+ SELECT partner_id, %s
+ FROM res_company
+ WHERE %s is not null""" %(
+ openupgrade.get_legacy_name('logo'),
+ openupgrade.get_legacy_name('logo')))
+ for row in cr.fetchall():
+ vals = {'image': row[1]}
+ partner_obj.write(cr, SUPERUSER_ID, row[0], vals)
+
@openupgrade.migrate()
def migrate(cr, version):
pool = pooler.get_pool(cr.dbname)
@@ -207,6 +224,7 @@
migrate_partner_address(cr, pool)
update_users_partner(cr, pool)
reset_currency_companies(cr, pool)
+ migrate_res_company_logo(cr, pool)
openupgrade.load_xml(
cr, 'base',
'migrations/7.0.1.3/data.xml')
=== modified file 'openerp/addons/base/migrations/7.0.1.3/pre-migration.py'
--- openerp/addons/base/migrations/7.0.1.3/pre-migration.py 2013-07-25 06:41:59 +0000
+++ openerp/addons/base/migrations/7.0.1.3/pre-migration.py 2013-10-16 21:36:14 +0000
@@ -38,8 +38,11 @@
# orm can map timestamp fields to date field
'res_users': [
('date', 'login_date'),
- ('user_email', openupgrade.get_legacy_name('user_email')),
- ]
+ ('user_email', None),
+ ],
+ 'res_company': [
+ ('logo', None),
+ ]
}
xmlid_renames = []
Follow ups