[FIX] web_m2x_options: fix test_ir_config_parameter

pull/2174/head
nguyenhk 2021-12-21 10:22:55 +07:00
parent e7e795ccdd
commit 31a5e8e947
2 changed files with 9 additions and 13 deletions

View File

@ -14,7 +14,5 @@ class IrConfigParameter(models.Model):
"web_m2x_options.m2o_dialog", "web_m2x_options.m2o_dialog",
"web_m2x_options.field_limit_entries", "web_m2x_options.field_limit_entries",
] ]
return { values = self.sudo().search_read([["key", "in", opts]], ["key", "value"])
res["key"]: res["value"] return {res["key"]: res["value"] for res in values}
for res in self.sudo().search_read([["key", "in", opts]], ["key", "value"])
}

View File

@ -16,15 +16,13 @@ class TestIrConfigParameter(common.TransactionCase):
def test_web_m2x_options_key(self): def test_web_m2x_options_key(self):
web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options() web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options()
options = {opt["key"]: opt["value"] for opt in web_m2x_options} self.assertIn("web_m2x_options.limit", web_m2x_options)
self.assertIn("web_m2x_options.limit", options) self.assertNotIn("web_m2x_options.m2o_dialog_test", web_m2x_options)
self.assertNotIn("web_m2x_options.m2o_dialog_test", options)
def test_web_m2x_options_value(self): def test_web_m2x_options_value(self):
web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options() web_m2x_options = self.env["ir.config_parameter"].get_web_m2x_options()
options = {opt["key"]: opt["value"] for opt in web_m2x_options} self.assertEqual(web_m2x_options["web_m2x_options.limit"], "10")
self.assertEqual(options["web_m2x_options.limit"], "10") self.assertTrue(bool(web_m2x_options["web_m2x_options.create_edit"]))
self.assertTrue(bool(options["web_m2x_options.create_edit"])) self.assertTrue(bool(web_m2x_options["web_m2x_options.create"]))
self.assertTrue(bool(options["web_m2x_options.create"])) self.assertEqual(web_m2x_options["web_m2x_options.search_more"], "False")
self.assertEqual(options["web_m2x_options.search_more"], "False") self.assertTrue(bool(web_m2x_options["web_m2x_options.m2o_dialog"]))
self.assertTrue(bool(options["web_m2x_options.m2o_dialog"]))