diff options
| author | Xavier Morel <xmo@odoo.com> | 2018-10-26 11:39:53 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2018-10-26 11:39:53 +0000 |
| commit | 8c9174ff80cf7d6be1e212935d5b7e26b737d5cd (patch) | |
| tree | 81e4b2a2a9bcf29dd2f2e899e3c7670aa216e1e3 /odoo | |
| parent | bf65793b310e5eea7fd1f795bd2b148f3e6c2d83 (diff) | |
[FIX] base: handling of *_view_ref in SSF
The feature was not tested, and as it turns out completely broken:
* the non-raw string means the "backrefs" were really interpreted as
octal literals
* the second backref was entirely wrong
Also add all loaded views to the field descriptor in case we might
have a use for it (and because inline sub-views are always stored on
the descriptor).
closes odoo/odoo#28194
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/addons/test_testing_utilities/tests/test_form_impl.py | 14 | ||||
| -rw-r--r-- | odoo/tests/common.py | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/odoo/addons/test_testing_utilities/tests/test_form_impl.py b/odoo/addons/test_testing_utilities/tests/test_form_impl.py index 2232e872dc6..a14d6b93974 100644 --- a/odoo/addons/test_testing_utilities/tests/test_form_impl.py +++ b/odoo/addons/test_testing_utilities/tests/test_form_impl.py @@ -284,6 +284,20 @@ class TestO2M(TransactionCase): delegating to a separate form view """ f = Form(self.env['test_testing_utilities.parent'], view='test_testing_utilities.o2m_parent_ed') + custom_tree = self.env.ref('test_testing_utilities.editable_external').id + + subs_field = f._view['fields']['subs'] + tree_view = subs_field['views']['tree'] + self.assertEqual(tree_view['type'], 'tree') + self.assertEqual( + tree_view['view_id'], custom_tree, + 'check that the tree view is the one referenced by tree_view_ref' + ) + self.assertIs(subs_field['views']['edition'], tree_view, "check that the edition view is the tree view") + self.assertEqual( + subs_field['views']['edition']['view_id'], + custom_tree + ) with f.subs.new() as s: s.value = 1 diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 49a026b52aa..bd1a4f0eda2 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -989,10 +989,10 @@ def can_import(module): # TODO: sub-views (o2m, m2m) -> sub-form? # TODO: domains -ref_re = re.compile(""" +ref_re = re.compile(r""" # first match 'form_view_ref' key, backrefs are used to handle single or # double quoting of the value -(['"])(?P<view_type>\w+)_view_ref\1 +(['"])(?P<view_type>\w+_view_ref)\1 # colon separator (with optional spaces around) \s*:\s* # open quote for value @@ -1003,7 +1003,7 @@ ref_re = re.compile(""" [.\w]+ ) # close with same quote as opening -\2 +\3 """, re.VERBOSE) class Form(object): """ Server-side form view implementation (partial) @@ -1119,6 +1119,8 @@ class Form(object): .load_views([(False, 'tree'), (False, 'form')])['fields_views'] # embedded views should take the priority on externals views.update(descr['views']) + # re-set all resolved views on the descriptor + descr['views'] = views # if the default view is a kanban or a non-editable list, the # "edition controller" is the form view |
