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

[14.0][FIX] account_credit_control: constraints name no spaces #186

Merged

Conversation

Abranes
Copy link
Member

@Abranes Abranes commented May 9, 2022

Odoo doesn't allow spaces in external IDs and all sql_constrains generate an external ID.

Here is the runboat error: https://runboat.odoo-community.org/api/v1/builds/b5dd9f999-992d-49ff-9377-276f13439c7a/init-log

2022-05-09 00:46:54,790 52 ERROR b5dd9f999-992d-49ff-9377-276f13439c7a odoo.sql_db: bad query: 
            INSERT INTO ir_model_data (module, name, model, res_id, noupdate)
            VALUES ('account_credit_control', 'constraint_credit_control_policy_level_unique level', 'ir.model.constraint', 911, false)
            ON CONFLICT (module, name)
            DO UPDATE SET (model, res_id, write_date) =
                (EXCLUDED.model, EXCLUDED.res_id, now() at time zone 'UTC')
                
        
ERROR: new row for relation "ir_model_data" violates check constraint "ir_model_data_name_nospaces"
DETAIL:  Failing row contains (13578, null, 2022-05-09 00:46:54.151204, 2022-05-09 00:46:54.151204, null, f, constraint_credit_control_policy_level_unique level, account_credit_control, ir.model.constraint, 911).
 
2022-05-09 00:46:54,791 52 ERROR b5dd9f999-992d-49ff-9377-276f13439c7a odoo.addons.base.models.ir_model: Failed to insert ir_model_data
('account_credit_control', 'constraint_credit_control_policy_level_unique level', 'ir.model.constraint', 911, False) 
2022-05-09 00:46:54,793 52 WARNING b5dd9f999-992d-49ff-9377-276f13439c7a odoo.modules.loading: Transient module states were reset 
2022-05-09 00:46:54,806 52 ERROR b5dd9f999-992d-49ff-9377-276f13439c7a odoo.modules.registry: Failed to load registry 
2022-05-09 00:46:54,806 52 CRITICAL b5dd9f999-992d-49ff-9377-276f13439c7a odoo.service.server: Failed to initialize database `b5dd9f999-992d-49ff-9377-276f13439c7a`. 
Traceback (most recent call last):
  File "/opt/odoo/odoo/service/server.py", line 1201, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/opt/odoo/odoo/modules/registry.py", line 89, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/odoo/modules/loading.py", line 461, in load_modules
    loaded_modules, update_module, models_to_check)
  File "/opt/odoo/odoo/modules/loading.py", line 349, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/opt/odoo/odoo/modules/loading.py", line 199, in load_module_graph
    registry.init_models(cr, model_names, {'module': package.name}, new_install)
  File "/opt/odoo/odoo/modules/registry.py", line 411, in init_models
    env['ir.model.constraint']._reflect_constraints(model_names)
  File "/opt/odoo/odoo/addons/base/models/ir_model.py", line 1574, in _reflect_constraints
    self._reflect_model(self.env[model_name])
  File "/opt/odoo/odoo/addons/base/models/ir_model.py", line 1598, in _reflect_model
    self.env['ir.model.data']._update_xmlids(data_list)
  File "/opt/odoo/odoo/addons/base/models/ir_model.py", line 2038, in _update_xmlids
    self.env.cr.execute(query, [arg for row in sub_rows for arg in row])
  File "<decorator-gen-3>", line 2, in execute
  File "/opt/odoo/odoo/sql_db.py", line 101, in check
    return f(self, *args, **kwargs)
  File "/opt/odoo/odoo/sql_db.py", line 298, in execute
    res = self._obj.execute(query, params)
psycopg2.IntegrityError: new row for relation "ir_model_data" violates check constraint "ir_model_data_name_nospaces"
DETAIL:  Failing row contains (13578, null, 2022-05-09 00:46:54.151204, 2022-05-09 00:46:54.151204, null, f, constraint_credit_control_policy_level_unique level, account_credit_control, ir.model.constraint, 911).

@Abranes
Copy link
Member Author

Abranes commented May 9, 2022

@pedrobaeza

@pedrobaeza pedrobaeza added this to the 14.0 milestone May 9, 2022
@pedrobaeza
Copy link
Member

Please include the migration script.

This was referenced May 9, 2022
@Abranes
Copy link
Member Author

Abranes commented May 10, 2022

Migration script for? The external ID doesn't get created due to the error, so I don't think a migration script is needed.

@pedrobaeza
Copy link
Member

This seems a new constraint introduced in the middle of the lifecycle, so existing users with the previous one will have to manually delete it. Or other users coming from 13.0 will find the same problem, isn't it?

@Abranes Abranes force-pushed the 14.0-fix-account_credit_control-constrains_name branch from 0708fb2 to c9b6a3c Compare May 11, 2022 07:32
@Abranes
Copy link
Member Author

Abranes commented May 11, 2022

This seems a new constraint introduced in the middle of the lifecycle, so existing users with the previous one will have to manually delete it. Or other users coming from 13.0 will find the same problem, isn't it?

Ready, you could review it?

Copy link
Contributor

@pedrocasi pedrocasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@pedrobaeza
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 14.0-ocabot-merge-pr-186-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d8c2b79 into OCA:14.0 May 11, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 3e15d28. Thanks a lot for contributing to OCA. ❤️

@Abranes Abranes deleted the 14.0-fix-account_credit_control-constrains_name branch May 12, 2022 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants