Search code examples
pythonodooodoo-9

Odoo Migrations


I have some modules which expand add-ons of Odoo. For example, models in my_module which expand crm:

class Lead(models.Model):
    _inherit = 'crm.lead'
    # exmaple fields
    field_1 = fields.Char(...)
    field_2 = fields.Many2one(...)
    # ... field 99


class Stage(models.Model):
    _inherit = 'crm.stage'
    # exmaple fields
    field_1 = fields.Char(...)
    field_2 = fields.Many2one(...)
    # ... field 99

The same situation is for modules which expand hr, product, etc. I need to make some changes to the models. For example, in my_module_1, I need to change a couple of fields(type, relation), in my_module_2, just to remove a few fields etc. Of course I also need to change views of each module. And of course I have my custom models which have dependencies with models from different apps/modules. But I have data on production which must be stored. I did not find any information about migrations(or synchronization of modules) in Odoo.

My question is: What is the best way to update modules/apps on production(if we have many changes in fields of models and views)? Thanks in advance.


Solution

  • My question is: What is the best way to update modules/apps on production(if we have many changes in fields of models and views)?

    While this question has been around for a while I cannot see any canonical answer therefore here are my two cents.

    The problem of migration from one version to another in Odoo is rather common and definitely complicated. With that in mind the OpenUpgrade project has been created. OpenUpgrade is basically an upgrade path that will help you transform your data and models from version A to version B. For example if a field named fieldA has had its type changed on version 9 and you are on version 8, OpenUpgrade will take care of this by doing the necessary transformations.

    OpenUpgrade also gives you the possibility to create your own migration scripts that will do whatever needs to be done in order for your module to be forward ported (or back ported) in various versions. For the standard modules these scripts have already been written to an extend, but for your own you might need to do some writing.

    I suggest that you take a look at the documentation above, this is basically your first stop when we talk about migrations in Odoo.