Skip to content

Commit

Permalink
[17.0] Migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
onurugur committed Jun 14, 2024
1 parent ac179e0 commit 04bab5a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exclude = ["setup/*"]
"__manifest__.py" = ["B018"] # useless expression

[lint.isort]
section-order = ["future", "standard-library", "third- party", "odoo", "odoo-addons", "first-party", "local-folder"]
section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"]

[lint.isort.sections]
"odoo" = ["odoo"]
Expand Down
14 changes: 7 additions & 7 deletions attribute_set/models/attribute_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def _build_attribute_field(self, attribute_egroup):
Conditional invisibility based on its attribute sets.
"""
self.ensure_one()
kwargs = {"name": "%s" % self.name}
kwargs = {"name": f"{self.name}"}
if self.attribute_set_ids:
attribute_sets = self.attribute_set_ids.ids
kwargs["invisible"] = "attribute_set_id not in %s"%attribute_sets
kwargs["invisible"] = f"attribute_set_id not in {attribute_sets}"
if self.required or self.required_on_views:
kwargs['required'] = "attribute_set_id in %s"%attribute_sets
kwargs['required'] = f"attribute_set_id in {attribute_sets}"
if self.widget:
kwargs["widget"] = self.widget

Expand All @@ -149,7 +149,7 @@ def _build_attribute_field(self, attribute_egroup):
else:
# Display only options linked to an existing object
ids = [op.value_ref.id for op in self.option_ids if op.value_ref]
kwargs["domain"] = "[('id', 'in', %s)]" % ids
kwargs["domain"] = f"[('id', 'in', {ids})]"
# Add color options if the attribute's Relational Model
# has a color field
relation_model_obj = self.env[self.relation_model_id.model]
Expand All @@ -158,8 +158,8 @@ def _build_attribute_field(self, attribute_egroup):
elif self.nature == "custom":
# Define field's domain and context with attribute's id to go along with
# Attribute Options search and creation
kwargs["domain"] = "[('attribute_id', '=', %s)]" % (self.id)
kwargs["context"] = "{'default_attribute_id': %s}" % (self.id)
kwargs["domain"] = f"[('attribute_id', '=', {self.id})]"
kwargs["context"] = f"{{'default_attribute_id': {self.id}}}"
elif self.nature != "custom":
kwargs["context"] = self._get_native_field_context()

Expand Down Expand Up @@ -234,7 +234,7 @@ def onchange_field_description(self):
def onchange_name(self):
name = self.name
if not name.startswith("x_"):
self.name = "x_%s" % name
self.name = f"x_{name}"

@api.onchange("attribute_type")
def onchange_attribute_type(self):
Expand Down
4 changes: 2 additions & 2 deletions attribute_set/tests/test_build_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _create_attribute(cls, vals):

@classmethod
def setUpClass(cls):
super(BuildViewCase,cls).setUpClass()
super().setUpClass()

# Demo user will be a base user to read model
cls.demo = cls.env.ref("base.user_demo")
Expand Down Expand Up @@ -163,7 +163,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.loader.restore_registry()
return super(BuildViewCase, cls).tearDownClass()
return super().tearDownClass()

# TEST write on attributes
@users("demo")
Expand Down
4 changes: 2 additions & 2 deletions attribute_set/tests/test_custom_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def _create_attribute(self, vals):
{
"nature": "custom",
"model_id": self.model_id,
"field_description": "Attribute %s" % vals["attribute_type"],
"name": "x_%s" % vals["attribute_type"],
"field_description": "Attribute {}".format(vals["attribute_type"]),
"name": "x_{}".format(vals["attribute_type"]),
"attribute_group_id": self.group.id,
}
)
Expand Down

0 comments on commit 04bab5a

Please sign in to comment.