Skip to content

Commit

Permalink
[FIX] product_packaging_level: adjust rename hook to keep data
Browse files Browse the repository at this point in the history
  • Loading branch information
trisdoan committed Jan 23, 2025
1 parent 311bf2d commit 34bf223
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions product_packaging_level/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@
def pre_init_hook(cr):
if openupgrade.table_exists(cr, "product_packaging_type"):
env = api.Environment(cr, SUPERUSER_ID, {})
# Re-mapping the name for the xml record to be the same as the new version
openupgrade.logged_query(

Check warning on line 12 in product_packaging_level/hooks.py

View check run for this annotation

Codecov / codecov/patch

product_packaging_level/hooks.py#L12

Added line #L12 was not covered by tests
cr,
query="""
UPDATE ir_model_data
SET name = 'product_packaging_level_default'
WHERE name = 'product_packaging_type_default'
AND module = 'product_packaging_type';
""",
)

# Former version of the module is present
models = [("product.packaging.type", "product.packaging.level")]
openupgrade.rename_models(env.cr, models)
tables = [("product_packaging_type", "product_packaging_level")]
openupgrade.rename_tables(env.cr, tables)

Check warning on line 26 in product_packaging_level/hooks.py

View check run for this annotation

Codecov / codecov/patch

product_packaging_level/hooks.py#L25-L26

Added lines #L25 - L26 were not covered by tests
fields = [
(
"product.packaging",
Expand Down

0 comments on commit 34bf223

Please sign in to comment.