openupgrade-drivers team mailing list archive
-
openupgrade-drivers team
-
Mailing list archive
-
Message #00157
Re: OpenERP 7.0 upgrade
On 06/17/2013 06:42 PM, Ondrej Kuznik wrote:
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.
Hi Ondrej,
thanks in advance for sharing your work, albeit unfinished. I am sure it
will be of great help to other developers!
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?
For version specific API, maybe have a specific module such as
openerp/openupgrade/openupgrade70.py (just an example, I am sure someone
can come up with a better naming convention). How does that sound to you?
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?
Yes, that would be a very good addition!
Thanks,
Stefan.
--
Therp - Maatwerk in open ontwikkeling
Stefan Rijnhart - Ontwerp en implementatie
mail: stefan@xxxxxxxx
tel: +31 (0) 614478606
http://therp.nl
https://twitter.com/therp_stefan
Follow ups
References