0

My problem: I want to migrate lots of modules from OpenERP7 to Odoo 12.

I was thinking about reading the file and perform the migrations for fields, class names etc. all by searching on strings like "class" "def", "field".

There must be a better way to just "read" the python file so you've got the class defenitions etc. without actually "running" the code.

So actually the question is: Is there another way of migrating just the code than reading the plain text and process it?

for example my file in / output would be something like this

input

class res_partner(osv.osv):

    _columns = {
        'name': fields.char(
            string='Name'
        )
    }

    _defaults = {
        'name': 'MyDefaultName'
    }

output

class ResPartner(Models.Model):

    name = fields.Char(
        string='Name'
        default='MyDefaultName'
    )

I know this is only part of the migration but if I'd be able to write a script for the bulk it would save lots of time.

JordyRitzen
  • 592
  • 5
  • 21
  • The only thing that comes to mind is to replace using regular expresions in your code editor. It is better than nothing – ChesuCR Dec 25 '18 at 23:24
  • You can 'read' and modify source files using python's built in [ast](https://docs.python.org/3/library/ast.html) module, or maybe a tool like [Red Baron](https://redbaron.readthedocs.io/en/latest/modifying.html). – snakecharmerb Jan 04 '19 at 10:59

0 Answers0