Skip to content

Commit

Permalink
[MIG] component: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenminhchien committed Nov 24, 2023
1 parent 47c5396 commit ba5e2e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion component/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Components",
"summary": "Add capabilities to register and use decoupled components,"
" as an alternative to model classes",
"version": "16.0.1.1.1",
"version": "17.0.1.0.0",
"author": "Camptocamp," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "LGPL-3",
Expand Down
29 changes: 14 additions & 15 deletions component/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ def component_by_name(self, name, model_name=None):
and self.collection._name != component_class._collection
):
raise NoComponentError(
"Component with name '%s' can't be used for collection '%s'."
% (name, self.collection._name)
"Component with name '{}' can't be used for collection '{}'.".format(
name, self.collection._name
)
)

if (
Expand All @@ -337,10 +338,11 @@ def component_by_name(self, name, model_name=None):
else:
hint_models = f"<one of {component_class.apply_on_models!r}>"
raise NoComponentError(
"Component with name '%s' can't be used for model '%s'.\n"
"Component with name '{}' can't be used for model '{}'.\n"
"Hint: you might want to use: "
"component_by_name('%s', model_name=%s)"
% (name, work_model, name, hint_models)
"component_by_name('{}', model_name={})".format(
name, work_model, name, hint_models
)
)

if work_model == self.model_name:
Expand Down Expand Up @@ -429,9 +431,8 @@ def component(self, usage=None, model_name=None, **kw):
)
if not component_classes:
raise NoComponentError(
"No component found for collection '%s', "
"usage '%s', model_name '%s'."
% (self.collection._name, usage, model_name)
f"No component found for collection '{self.collection._name}', "
f"usage '{usage}', model_name '{model_name}'."
)
elif len(component_classes) > 1:
# If we have more than one component, try to find the one
Expand All @@ -444,9 +445,8 @@ def component(self, usage=None, model_name=None, **kw):
)
if len(component_classes) != 1:
raise SeveralComponentError(
"Several components found for collection '%s', "
"usage '%s', model_name '%s'. Found: %r"
% (
"Several components found for collection '{}', "
"usage '{}', model_name '{}'. Found: {}".format(
self.collection._name,
usage or "",
model_name or "",
Expand Down Expand Up @@ -831,9 +831,9 @@ def _build_component(cls, registry):

if cls._name in registry and not parents:
raise TypeError(
"Component %r (in class %r) already exists. "
f"Component {cls._name} (in class {cls}) already exists. "
"Consider using _inherit instead of _name "
"or using a different _name." % (cls._name, cls)
"or using a different _name."
)

# determine the component's name
Expand Down Expand Up @@ -871,8 +871,7 @@ def _build_component(cls, registry):
for parent in parents:
if parent not in registry:
raise TypeError(
"Component %r inherits from non-existing component %r."
% (name, parent)
f"Component {name} inherits from non-existing component {parent}."
)
parent_class = registry[parent]
if parent == name:
Expand Down

0 comments on commit ba5e2e1

Please sign in to comment.