Skip to content
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

[16.0][MIG+IMP] product_category_code_unique: restriciton options #1829

Open
wants to merge 13 commits into
base: 16.0
Choose a base branch
from

Conversation

manuelregidor
Copy link
Contributor

Based on #1750

T-6836

Copy link
Contributor

@luis-ron luis-ron left a comment

Choose a reason for hiding this comment

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

Functional Review: LGTM 👍🏻

Copy link

@Tisho99 Tisho99 left a comment

Choose a reason for hiding this comment

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

Technical review.

Some comments

@manuelregidor manuelregidor force-pushed the 16.0-mig-product_category_code_unique branch from 3df71c1 to 49d1df1 Compare January 7, 2025 07:49
@manuelregidor
Copy link
Contributor Author

@Tisho99 Could you reviw again, please?

Copy link

@Tisho99 Tisho99 left a comment

Choose a reason for hiding this comment

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

LGTM

@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). 🤖

@rousseldenis
Copy link
Contributor

/ocabot migration product_category_code_unique

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Jan 7, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Jan 7, 2025
57 tasks
@rousseldenis
Copy link
Contributor

@manuelregidor Could you maybe split the migration changes from improvements in commits ?

self.ensure_one()
return self._get_parents() + self._get_children()

def _code_restriction(self, restriction=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, the restriction attribute is not useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The restriction attribute has been added so it can be passed when the method is called from _check_product_cat_code_unique_restriction in res.config.settings model. _check_product_cat_code_unique_restriction in res.config.settings is executed before the system parameter is modified changed, so we need to pass the selected restriction to the _code_restriction method in product.category to check whether the restriction option can be changed.

product_category_code_unique/models/res_config_settings.py Outdated Show resolved Hide resolved
product_category_code_unique/models/product_category.py Outdated Show resolved Hide resolved
to_check = cat._get_hierarchy_cats()
domain = [("code", "=", cat.code), ("id", "in", to_check.ids)]
within = _("category hierarchy")
if self.search_count(domain) > 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, this should be avoided for performance reasons.

A query to get all the categories should be done outside the loop. Then, compare the recordset values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, but I don't know exactly what you mean here.

@manuelregidor manuelregidor force-pushed the 16.0-mig-product_category_code_unique branch from 49d1df1 to d7949da Compare January 7, 2025 13:50
@manuelregidor
Copy link
Contributor Author

@rousseldenis Thanks for your feedback. I've already split the changes into 2 commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants