[IMP] update pre-commit

This commit is contained in:
JordiMForgeFlow
2023-07-06 16:50:56 +02:00
parent ddd0ff6f37
commit 6c496c114a
16 changed files with 92 additions and 78 deletions

View File

@@ -13,7 +13,8 @@ class ExternalSystem(models.Model):
_description = "External System"
name = fields.Char(
required=True, help="This is the canonical (humanized) name for the system.",
required=True,
help="This is the canonical (humanized) name for the system.",
)
host = fields.Char(
help="This is the domain or IP address that the system can be reached " "at.",
@@ -56,7 +57,10 @@ class ExternalSystem(models.Model):
default=lambda s: [(6, 0, s.env.user.company_id.ids)],
help="Access to this system is restricted to these companies.",
)
system_type = fields.Selection(selection="_get_system_types", required=True,)
system_type = fields.Selection(
selection="_get_system_types",
required=True,
)
interface = fields.Reference(
selection="_get_system_types",
readonly=True,

View File

@@ -43,12 +43,15 @@ class TestExternalSystem(Common):
{"name": "Test", "system_type": "external.system.os"}
)
self.assertEqual(
record.interface._name, "external.system.os",
record.interface._name,
"external.system.os",
)
def test_create_context_override(self):
"""It should allow for interface create override with context."""
model = self.env["external.system"].with_context(no_create_interface=True,)
model = self.env["external.system"].with_context(
no_create_interface=True,
)
record = model.create({"name": "Test", "system_type": "external.system.os"})
self.assertFalse(record.interface)

View File

@@ -50,7 +50,7 @@ class Base(models.AbstractModel):
# To generate externals IDS.
match.export_data(fields)
ext_id = match.get_external_id()
row["id"] = ext_id[match.id] if match else row.get("id", u"")
row["id"] = ext_id[match.id] if match else row.get("id", "")
# Store the modified row, in the same order as fields
newdata.append(tuple(row[f] for f in fields))
# We will import the patched data to get updates on matches

View File

@@ -42,7 +42,7 @@ class BaseImportMatch(models.Model):
def _compute_name(self):
"""Automatic self-descriptive name for the setting records."""
for one in self:
one.name = u"{}: {}".format(
one.name = "{}: {}".format(
one.model_id.display_name,
" + ".join(one.field_ids.mapped("display_name")),
)
@@ -163,9 +163,10 @@ class BaseImportMatchField(models.Model):
@api.depends("conditional", "field_id", "imported_value")
def _compute_display_name(self):
for one in self:
pattern = u"{name} ({cond})" if one.conditional else u"{name}"
pattern = "{name} ({cond})" if one.conditional else "{name}"
one.display_name = pattern.format(
name=one.field_id.name, cond=one.imported_value,
name=one.field_id.name,
cond=one.imported_value,
)
@api.onchange("field_id", "match_id", "conditional", "imported_value")

View File

@@ -86,9 +86,12 @@ class ImportCase(TransactionCase):
self.assertEqual(
self.env.ref("base.res_partner_address_4").function, "Bug Fixer"
)
self.assertTrue(self.env.ref("base.res_partner_address_4").child_ids,)
self.assertTrue(
self.env.ref("base.res_partner_address_4").child_ids,
)
self.assertEqual(
len(self.env.ref("base.res_partner_address_4").child_ids), 3,
len(self.env.ref("base.res_partner_address_4").child_ids),
3,
)
self.assertEqual(
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.name")),

View File

@@ -34,7 +34,9 @@ class ResUsersRole(models.Model):
help="Associated group's category",
readonly=False,
)
comment = fields.Html(string="Internal Notes",)
comment = fields.Html(
string="Internal Notes",
)
@api.depends("line_ids.user_id")
def _compute_user_ids(self):

View File

@@ -31,7 +31,8 @@ class IrActionsServerNavigateLine(models.Model):
def _onchange_field_id(self):
# check out the docstring of this in odoo/models.py
lines = self.action_id.resolve_2many_commands(
"navigate_line_ids", self.env.context.get("navigate_line_ids", []),
"navigate_line_ids",
self.env.context.get("navigate_line_ids", []),
)
lines = sum(map(self.new, lines), self.browse([]))
model = lines[-1:].field_id.relation or self.action_id.model_id.model