8000 [18.0][MIG] product_attribute_value_archive: Migration to 18.0 by LucasTran380381 · Pull Request #394 · OCA/product-variant · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[18.0][MIG] product_attribute_value_archive: Migration to 18.0 #394

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

Merged

Conversation

LucasTran380381
Copy link
  • Product attribute value has active field
    image
  • when delete attribute module will archive instead of unlink
    image

Copy link
@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -18,7 +18,7 @@ def _get_related_variants(self):
product.
"""
self.ensure_one()
self.flush()
self.flush_recordset()

Choose a reason for hiding this comment

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

Actually, here, we must flush all fields used in the query... and not only those of the recordset.

I think we need to do something like this:

self.env["product.product"].flush_model(
    [
        "product_template_attribute_value_ids",
        "product_template_variant_value_ids",
    ]
)
self.env["product.template.attribute.value"].flush_model(["product_attribute_value_id"])

@@ -47,6 +47,7 @@ def _get_pav_to_archive(self):
related_variants = pav._get_related_variants()
# Archive only if all related variants are archived
# (none is active)
related_variants.fetch(["active"])

Choose a reason for hiding this comment

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

Why is this explicit fetch needed here? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

mapped will get all field in table "product.product"
image

we will fetch only field active
image

Choose a reason for hiding this comment

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

So this is a performance optimization to no get prefetch all fields.
Similar to related_variants.with_context(prefetch_fields=False).mapped('active')

Perhaps keep an inline comment explaining the purpose

@LucasTran380381 LucasTran380381 force-pushed the 18.0-mig-product_attribute_value_archive branch from 466a381 to 8de0ae8 Compare February 10, 2025 02:42
@@ -47,6 +47,7 @@ def _get_pav_to_archive(self):
related_variants = pav._get_related_variants()
# Archive only if all related variants are archived
# (none is active)
related_variants.fetch(["active"])

Choose a reason for hiding this comment

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

So this is a performance optimization to no get prefetch all fields.
Similar to related_variants.with_context(prefetch_fields=False).mapped('active')

Perhaps keep an inline comment explaining the purpose

@LucasTran380381 LucasTran380381 force-pushed the 18.0-mig-product_attribute_value_archive branch 2 times, most recently from 4102de8 to e84be38 Compare February 11, 2025 08:48
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@LucasTran380381 LucasTran380381 force-pushed the 18.0-mig-product_attribute_value_archive branch from e84be38 to 805a39c Compare February 24, 2025 02:55
@rousseldenis rousseldenis added this to the 18.0 milestone Feb 25, 2025
@rousseldenis
Copy link

/ocabot migration product_attribute_value_archive

@OCA-git-bot OCA-git-bot mentioned this pull request Feb 25, 2025
4 tasks
@rousseldenis
Copy link

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-394-by-rousseldenis-bump-nobump, awaiting test results.

@OCA-git-bot
Copy link
Contributor

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

@OCA-git-bot OCA-git-bot merged commit aeff3fe into OCA:18.0 Feb 25, 2025
7 checks passed
@hparfr
Copy link
hparfr commented Mar 11, 2025

Why auto_install = True ? (I know it was like that in v13).

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.

7 participants
0