Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REM] base: Removed login_key constraint to avoid errors on log #382

Closed

Conversation

moylop260
Copy link

When we execute -u all to update all modules, Odoo loads the
constraints 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 the login
field unique. Later, the website module replaces this constraint by
making unique the combination of login and website_id, to allow
users 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 to
recreate the constraint with its original definition, but it will fail
as there are already multiple users with the same login (but on
different websites).

This patch is removing in the original definition of the constraint,
leaving the work on the website module to create it with the new
definition, and avoid the error when running -u all.

More here:

Odoo tried to fixed here:

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 work
Since that Odoo does not have a way to load a module before to base one

This patch is required in DeployV since that a -u all is executed
in 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.

When we execute `-u all` to update all modules, Odoo loads the
constraints 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 the `login`
field unique. Later, the `website` module replaces this constraint by
making unique the combination of `login` and `website_id`, to allow
users 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 to
recreate the constraint with its original definition, but it will fail
as there are already multiple users with the same `login` (but on
different websites).

This patch is removing in the original definition of the constraint,
leaving the work on the `website` module to create it with the new
definition, and avoid the error when running `-u all`.

More here:
 - odoo#40740 (comment)

Odoo tried to fixed here:
 - odoo#30334
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 work
Since that Odoo does not have a way to load a module before to `base` one

This patch is required in DeployV since that a `-u all` is executed
in 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.
@luisg123v luisg123v closed this Jul 14, 2022
@luisg123v luisg123v deleted the 12.0-rm-login-constraint-moy branch July 14, 2022 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants