Skip to content
Snippets Groups Projects
Commit 790cde7c authored by Adrian Torres's avatar Adrian Torres Committed by Raphael Collet
Browse files

[FIX] orm: don't log errors on constraint failure unless necessary


Given an scenario in which a field F of model M is defined in module X
as `required=True` and is extended by another module Y as
`required=False` in a database with data not satisfying the original
constraint:

During an upgrade of base the original constraint will be re-applied
on the data (and fail) even though it is no longer necessary because
module Y relaxes the NOT NULL constraint.

This failure in and of itself is non-blocking, the upgrade will go
through but an error and a warning are logged anyway which are not
problematic either except in the case of automated testing
infrastructure (such as runbot), because of this it would be best if
these errors would not be logged at all unless we're 100% sure that the
constraint that was applied is not relaxed downstream.

With this commit, we store potential NOT NULL constraint application
errors in a mapping and suppressing them if another extending module
relaxes any previous constraints, then after all modules have been
loaded we log any remaining errors within the mapping, as these would be
real NOT NULL constraint application errors.

This is not a proper fix as ideally these constraint applications
should not happen in the first place, but a proper fix may not be
suitable for stable. This commit also has the side effect of showing
errors after all module upgrades are done instead of showing the errors
after each module upgrade.

opw-2269220

closes odoo/odoo#53145

X-original-commit: 53fb37fa
Signed-off-by: default avatarRaphael Collet (rco) <rco@openerp.com>
Signed-off-by: default avatarAdrian Torres (adt) <adt@odoo.com>
parent f713994e
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment