OCA/contract

[16.0] contract: Error migrating from 15.0 to 16.0

Closed this issue · 5 comments

Describe the bug

When migrating from 15.0 to 16.0 the pre-migrations of the contract module is executed. This uses an analytic_distribution field introduced in the same version (SEE) through the analytic.mixin mixin. So it gives the error:

2024-02-01 06:40:16,933 234 INFO odoo.modules.migration: module contract: Running migration [>16.0.2.0.0] pre-migrate
2024-02-01 06:40:16,933 234 INFO pre-migrate: Migrating analytic distribution for contract.line
2024-02-01 06:40:16,934 234 ERROR odoo.sql_db: bad query:
SELECT id, analytic_account_id, analytic_distribution
FROM contract_line
WHERE analytic_account_id IS NOT NULL

ERROR: column "analytic_distribution" does not exist
LINE 2:             SELECT id, analytic_account_id, analytic_distrib...

On the other hand IMHO it is missing to add the explicit dependency to the analytic module.

ping @fkantelberg @CRogos @pedrobaeza

Put that part of the migration script in post instead of pre.

The dependency analytic is already part of it because contract -> account -> analytic.

Regarding the migration #1045 I tested it and the field is deleted later in the process

The dependency analytic is already part of it because contract -> account -> analytic.

I have always been an advocate of "better explicit than implicit".

Regarding the migration #1045 I tested it and the field is deleted later in the process

Thanks for your promptness

I have always been an advocate of "better explicit than implicit".

Then you need to add base as well, and a lot of dependencies that are not easy to maintain across versions. The Python zen here is not practical.

Implicit dependency would be the dependency website -> iap. Not listed in the dependency and you can't reach there but it's used in a python import.