[REM] base: Removed login_key constraint to avoid errors on log #382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we execute
-u all
to update all modules, Odoo loads theconstraints as it goes through the modules, without taking into account
that the constraints might be removed or updated in a child module.
In this case the
base
module adds a constraint to make thelogin
field unique. Later, the
website
module replaces this constraint bymaking unique the combination of
login
andwebsite_id
, to allowusers to register in the different websites.
The first time, and while there are no users registered on multiple
websites, this doesn't raise any issues. After any users registers in
multiple websites, when we try to run
-u all
again,base
will try torecreate the constraint with its original definition, but it will fail
as there are already multiple users with the same
login
(but ondifferent websites).
This patch is removing in the original definition of the constraint,
leaving the work on the
website
module to create it with the newdefinition, and avoid the error when running
-u all
.More here:
Odoo tried to fixed here:
But it is not working
In the OPW task:
https://www.odoo.com/my/task/2312592
They replied the following message:
After internal discussion, we do not plan
to support SQL constraint override in the near future.
Supporting all cases (especially relaxing a constraint in
various inherited modules) can become unnecessarily complex
for the added value.
Even if you inherit the method
_add_sql_constraints
this didn't workSince that Odoo does not have a way to load a module before to
base
oneThis patch is required in DeployV since that a
-u all
is executedin staging instance and the error is used to change the state of the build.
It will help to avoid to make a constraint that will not be used.