Skip to content

Conversation

@SirPyTech
Copy link

When the link between the variant and the odoo module at a specific version is lost (i.e. product.product.odoo_module_version_id is empty), the odoo.module._update_product() should be able to restore it.

Task https://odoo-community.org/my/task/909771.

@SirPyTech SirPyTech force-pushed the 14.0-update_module_version branch 3 times, most recently from b50aa2e to 5eb9b13 Compare September 15, 2025 13:46
Copy link

@petrus-v petrus-v left a comment

Choose a reason for hiding this comment

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

Looks good to me !

Comment on lines 97 to 108
for variant in product.product_variant_ids:
if not variant.odoo_module_version_id:
values = (
variant.product_template_attribute_value_ids.product_attribute_value_id
)
for value in values:
version = self.env[
"product.product"
]._get_version_with_attribute(module.module_version_ids, value)
if version:
variant.odoo_module_version_id = version
break

Choose a reason for hiding this comment

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

Not blockers, but just a suggestion for better readability.

Suggested change
for variant in product.product_variant_ids:
if not variant.odoo_module_version_id:
values = (
variant.product_template_attribute_value_ids.product_attribute_value_id
)
for value in values:
version = self.env[
"product.product"
]._get_version_with_attribute(module.module_version_ids, value)
if version:
variant.odoo_module_version_id = version
break
for variant in product.product_variant_ids.filtered(lambda prod: not prod.odoo_module_version_id):
values = (
variant.product_template_attribute_value_ids.product_attribute_value_id
)
for value in values:
version = self.env[
"product.product"
]._get_version_with_attribute(module.module_version_ids, value)
if not version:
continue
variant.odoo_module_version_id = version
break

Copy link
Member

Choose a reason for hiding this comment

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

Maybe even with a

variants = product.praduct_variant_ids.filtered(...)
for variant in variants:
    # (... )

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review!
Agreed, it is very nested; I removed one indentation level, please check if that looks better.

Copy link
Member

@yvaucher yvaucher left a comment

Choose a reason for hiding this comment

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

LGTM

@SirPyTech SirPyTech marked this pull request as draft September 16, 2025 14:55
When the link between the variant and the odoo module at a specific version is lost (i.e. product.product.odoo_module_version_id is empty),
the odoo.module._update_product() should be able to restore it.
@SirPyTech SirPyTech force-pushed the 14.0-update_module_version branch from 5eb9b13 to c251982 Compare September 16, 2025 15:00
@SirPyTech SirPyTech marked this pull request as ready for review September 16, 2025 15:00
@yvaucher
Copy link
Member

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-97-by-yvaucher-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 71844d9 into OCA:14.0 Sep 17, 2025
2 checks passed
@OCA-git-bot
Copy link
Contributor

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

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.

5 participants