Skip to content

Commit

Permalink
[ADD] manifestoo: select_addons_categories: allow to filter addons on…
Browse files Browse the repository at this point in the history
… given categories
  • Loading branch information
ThomasBinsfeld committed Oct 30, 2023
1 parent 9cf3935 commit 7aefef1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/manifestoo/addons_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ def remove_addon_names(self, addon_names: str) -> None:
self.remove(addon_name)
except KeyError:
pass

def filter_categories(self, addons_categories: str, addons_set: AddonsSet) -> None:
categories_list = [category for category in comma_split(addons_categories)]
addons_list = list(self)
for addon_name in addons_list:
addon = addons_set.get(addon_name)
if addon and addon.manifest.category not in categories_list:
self.remove(addon_name)
13 changes: 13 additions & 0 deletions src/manifestoo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def callback(
help="Exclude the Odoo core addons (CE and EE) for the given series.",
show_default=False,
),
filter_categories: Optional[str] = typer.Option(
None,
metavar="addon1,addon2,...",
help=(
"Comma separated list of addons categories to use as addons filter. "
"Filter out addons from the selected addons that don't belong to one "
"of these categories."
),
),
addons_path: Optional[str] = typer.Option(
None,
help="Expand addons path with this comma separated list of directories.",
Expand Down Expand Up @@ -209,6 +218,10 @@ def callback(
main_options.addons_selection.update(core_addons)
else:
main_options.addons_selection.difference_update(core_addons)
if filter_categories:
main_options.addons_selection.filter_categories(
filter_categories, main_options.addons_set
)
if main_options.addons_selection:
echo.info(str(main_options.addons_selection), bold_intro="Addons selection: ")
else:
Expand Down

0 comments on commit 7aefef1

Please sign in to comment.