[13.0][FIX] base: Avoid possible issues with missing categories#2380
Merged
pedrobaeza merged 1 commit intoOCA:13.0from Aug 4, 2020
Merged
[13.0][FIX] base: Avoid possible issues with missing categories#2380pedrobaeza merged 1 commit intoOCA:13.0from
pedrobaeza merged 1 commit intoOCA:13.0from
Conversation
Member
|
I don't get the change. Isn't the same? |
Member
|
If not, reorder the code for clarity |
Contributor
Author
|
I could have done this: for old_xmlid, new_xmlid in xmlid_renames_ir_module_category:
module, name = new_xmlid.split('.')
sql = "SELECT res_id FROM ir_model_data WHERE module=%s AND name=%s"
env.cr.execute(sql, (module, name))
new_row = env.cr.fetchone()
if new_row:
module, name = old_xmlid.split('.')
env.cr.execute(sql, (module, name))
old_row = env.cr.fetchone()
if old_row:
openupgrade_merge_records.merge_records(
env, "ir.module.category", [old_row[0]], new_row[0],
method="sql", model_table="ir_module_category")
else:
+ module, name = old_xmlid.split('.')
+ env.cr.execute(sql, (module, name))
+ old_row = env.cr.fetchone()
+ if old_row:
+ openupgrade.rename_xmlids(env.cr, [(old_xmlid, new_xmlid)])
- openupgrade.rename_xmlids(env.cr, [(old_xmlid, new_xmlid)])that shows clearly the change, but then I reordered it to avoid repeating: |
pedrobaeza
approved these changes
Aug 4, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some databases may have missing a category for some reason. Just in case, assure the old category exists to avoid errors in cases of missing a category.
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr