openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #02761
OpenERP 7.0 upgrade
Hi all,
I've spent some time working on preparing quite a lot of modules for
upgrade. Unfortunately, the project has recently lost priority and it
might be a while before I get to resume working on it, so I better
publish the work in progress.
Currently, none of the migration scripts have been tested beyond being
able to upgrade an empty database and support the dependent modules
doing the same.
In the process, there has been a bit of functionality missing and before
I publish a repository, I'd like to know whether my approach to adding
it was appropriate and where the code should belong to before I publish
the rest as a bzr branch(es):
1. Regarding the partner_address -> partner move, the base module has
created an extra column to facilitate the migration for everyone using
partner_address, but there is no code to call to perform it. The code I
came up with I as follows:
def partner_address_to_partner(cr, table, field):
cr.execute("""
UPDATE %(table)s
SET %(field)s = a.openupgrade_7_migrated_to_partner_id
FROM %(table)s t
JOIN res_partner_address a
ON t.%(field)s = a.id
WHERE t.%(field)s is not null""" % { 'table': table,
'field': field })
To make it available from other modules, given that this is v7 specific,
where should it go and how will they be able to access it?
2. There were a couple of many2one fields that have changed to
many2many. I could not find any code in openerp.openupgrade.openupgrade
to do this so we came up with this:
def many2one2many2many(cr, model, table, field, source_field=None):
if source_field is None:
source_field = openupgrade.get_legacy_name(field)
cr.execute('SELECT id, %(field)s '
'FROM %(table)s '
'WHERE %(field)s is not null' % {
'table': table,
'field': source_field,
})
for row in cr.fetchall():
model.write(cr, SUPERUSER_ID, row[0], {field: [(4, row[1])]})
Do you think it should go alongside the other tools in that module?
Thanks,
Ondrej
Attachment:
signature.asc
Description: OpenPGP digital signature