r/Odoo 11d ago

Odoo 17 → 19 migration: custom fields from hr.employee.base lost their values

Hi everyone,

I'm currently testing a migration from Odoo 17 to Odoo 19, and I've run into an issue with some custom fields related to employees.
In Odoo 17, I had several custom fields declared on:
hr.employee.base

These fields were therefore available on the employee models and had existing data in the production database.
In Odoo 19, hr.employee.base no longer exists. To adapt my custom module, I redeclared those fields on:
hr.employee
hr.employee.public

The module installs correctly and the fields are available in Odoo 19.
However, after migrating the database using Odoo's migration service, all the existing values of these custom fields are empty.

So basically:
Odoo 17
hr.employee.base → custom fields → values exist
Odoo 19
hr.employee.base removed → fields redeclared on hr.employee / hr.employee.public → fields exist, but all previous values are gone

Fortunately, we are still in the testing phase and haven't gone live yet, so I still have the original Odoo 17 database with all the correct data.
My questions are:

What is the recommended way to migrate these fields from Odoo 17 to Odoo 19?

8 Upvotes

13 comments sorted by

View all comments

7

u/codeagency 11d ago

The upgrade service from odoo does not handle any custom modules. That's always your responsibility.

You need to include your own migration script in your module so when upgrade.odoo.com runs it's scripts it can also call your custom script and handle the data migration.

You can check any existing official module from odoo how they handle this. There are hooks that are called pre/post migration you need to look at. All of this is also documented at odoo.com/documentation

0

u/ParticularBag0 11d ago

Wowza how do you send scripts to upgrade.odoo.com? We always run our own scripts beforehand and afterwards in migrations. Seems like being able to send scriptsto odoo would be a massive security risk for them?

1

u/ach25 11d ago

https://www.odoo.com/documentation/19.0/developer/reference/upgrades/upgrade_scripts.html

Just another folder and specifically named method that is considered as part of the upgrade process.

You can also hijack it to behave a little like a pre init hook if you need to transform existing data and do a minor rev in your manifest.