-
-
Notifications
You must be signed in to change notification settings - Fork 278
[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
[18.0][MIG] product_attribute_value_archive: Migration to 18.0 #394
Conversation
- Product attribute value has active field
- when delete attribute module will archive instead of unlink
There was a problem hiding this 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() |
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
466a381
to
8de0ae8
Compare
@@ -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"]) |
There was a problem hiding this comment.
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
4102de8
to
e84be38
Compare
This PR has the |
e84be38
to
805a39c
Compare
/ocabot migration product_attribute_value_archive |
/ocabot merge nobump |
Hey, thanks for contributing! Proceeding to merge this for you. |
Congratulations, your PR was merged at 3959c7e. Thanks a lot for contributing to OCA. ❤️ |
Why |