[FIX] base: settings access test

Probably since recent changes in the views architecture, and
because the test coverage was recently extended, this test
failed when l10n_mx_edit module was installed.

While verifying the current user has access to all the fields specified
in the settings view, we browse all the fields, including the ones in a sub-view:

<field name="x_ids">
	<tree>
		<field name="whatever">
	</tree>
</field>

x_ids being a settings field, but not whatever, which made the test fail.

To fix this problem, we check the fields belong to the res.config.settings
model before trying to access it.

closes odoo/odoo#104119

X-original-commit: 60f22b71063eada039f59321722e794c653acbde
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2022-10-26 01:58:46 +02:00
parent f830656f0e
commit 46f80759eb
+6 -1
View File
@@ -168,7 +168,12 @@ class TestResConfigExecute(TransactionCase):
settings_view_arch = etree.fromstring(settings.get_view(view_id=self.settings_view.id)['arch'])
seen_fields = set()
for node in settings_view_arch.iterdescendants(tag='field'):
seen_fields.add(node.get('name'))
fname = node.get('name')
if fname not in settings._fields:
# fname isn't a settings fields, but the field of a model
# linked to settings through a relational field
continue
seen_fields.add(fname)
models_to_check = defaultdict(set)
for field_name in seen_fields: