From ba5e2e152a022a7cb1161ff5f5c55ae4c23e5e8f Mon Sep 17 00:00:00 2001
From: chien <chien@trobz.com>
Date: Thu, 23 Nov 2023 16:05:32 +0700
Subject: [PATCH] [MIG] component: Migration to 17.0

---
 component/__manifest__.py |  2 +-
 component/core.py         | 29 ++++++++++++++---------------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/component/__manifest__.py b/component/__manifest__.py
index 7b62e6fbe..484fb8a3e 100644
--- a/component/__manifest__.py
+++ b/component/__manifest__.py
@@ -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",
diff --git a/component/core.py b/component/core.py
index 9bc4c6f46..a842f0f92 100644
--- a/component/core.py
+++ b/component/core.py
@@ -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 (
@@ -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:
@@ -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
@@ -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 "",
@@ -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
@@ -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: