mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] update pre-commit
This commit is contained in:
@@ -13,7 +13,8 @@ class ExternalSystem(models.Model):
|
|||||||
_description = "External System"
|
_description = "External System"
|
||||||
|
|
||||||
name = fields.Char(
|
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(
|
host = fields.Char(
|
||||||
help="This is the domain or IP address that the system can be reached " "at.",
|
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)],
|
default=lambda s: [(6, 0, s.env.user.company_id.ids)],
|
||||||
help="Access to this system is restricted to these companies.",
|
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(
|
interface = fields.Reference(
|
||||||
selection="_get_system_types",
|
selection="_get_system_types",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
|
|||||||
@@ -43,12 +43,15 @@ class TestExternalSystem(Common):
|
|||||||
{"name": "Test", "system_type": "external.system.os"}
|
{"name": "Test", "system_type": "external.system.os"}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
record.interface._name, "external.system.os",
|
record.interface._name,
|
||||||
|
"external.system.os",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_context_override(self):
|
def test_create_context_override(self):
|
||||||
"""It should allow for interface create override with context."""
|
"""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"})
|
record = model.create({"name": "Test", "system_type": "external.system.os"})
|
||||||
self.assertFalse(record.interface)
|
self.assertFalse(record.interface)
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class Base(models.AbstractModel):
|
|||||||
# To generate externals IDS.
|
# To generate externals IDS.
|
||||||
match.export_data(fields)
|
match.export_data(fields)
|
||||||
ext_id = match.get_external_id()
|
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
|
# Store the modified row, in the same order as fields
|
||||||
newdata.append(tuple(row[f] for f in fields))
|
newdata.append(tuple(row[f] for f in fields))
|
||||||
# We will import the patched data to get updates on matches
|
# We will import the patched data to get updates on matches
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class BaseImportMatch(models.Model):
|
|||||||
def _compute_name(self):
|
def _compute_name(self):
|
||||||
"""Automatic self-descriptive name for the setting records."""
|
"""Automatic self-descriptive name for the setting records."""
|
||||||
for one in self:
|
for one in self:
|
||||||
one.name = u"{}: {}".format(
|
one.name = "{}: {}".format(
|
||||||
one.model_id.display_name,
|
one.model_id.display_name,
|
||||||
" + ".join(one.field_ids.mapped("display_name")),
|
" + ".join(one.field_ids.mapped("display_name")),
|
||||||
)
|
)
|
||||||
@@ -163,9 +163,10 @@ class BaseImportMatchField(models.Model):
|
|||||||
@api.depends("conditional", "field_id", "imported_value")
|
@api.depends("conditional", "field_id", "imported_value")
|
||||||
def _compute_display_name(self):
|
def _compute_display_name(self):
|
||||||
for one in 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(
|
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")
|
@api.onchange("field_id", "match_id", "conditional", "imported_value")
|
||||||
|
|||||||
@@ -86,9 +86,12 @@ class ImportCase(TransactionCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.env.ref("base.res_partner_address_4").function, "Bug Fixer"
|
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(
|
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(
|
self.assertEqual(
|
||||||
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.name")),
|
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.name")),
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ class ResUsersRole(models.Model):
|
|||||||
help="Associated group's category",
|
help="Associated group's category",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
)
|
)
|
||||||
comment = fields.Html(string="Internal Notes",)
|
comment = fields.Html(
|
||||||
|
string="Internal Notes",
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends("line_ids.user_id")
|
@api.depends("line_ids.user_id")
|
||||||
def _compute_user_ids(self):
|
def _compute_user_ids(self):
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class IrActionsServerNavigateLine(models.Model):
|
|||||||
def _onchange_field_id(self):
|
def _onchange_field_id(self):
|
||||||
# check out the docstring of this in odoo/models.py
|
# check out the docstring of this in odoo/models.py
|
||||||
lines = self.action_id.resolve_2many_commands(
|
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([]))
|
lines = sum(map(self.new, lines), self.browse([]))
|
||||||
model = lines[-1:].field_id.relation or self.action_id.model_id.model
|
model = lines[-1:].field_id.relation or self.action_id.model_id.model
|
||||||
|
|||||||
Reference in New Issue
Block a user