Skip to content

Commit 6fc1656

Browse files
committed
Merge PR #5445 into 18.0
Signed-off-by legalsylvain
2 parents 827265f + 527770f commit 6fc1656

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from odoo import api
77
from odoo.exceptions import ValidationError
8+
from odoo.modules.module import get_resource_from_path
89
from odoo.tools import mute_logger
910

1011
from odoo.addons.base.models.ir_ui_view import NameManager, View
@@ -85,6 +86,21 @@ def _check_field_paths(self, node, field_paths, model_name, use):
8586
pass
8687

8788

89+
def _inverse_arch(self):
90+
"""
91+
Remove install_filename from context if it's from openupgrade_scripts.
92+
Without this, arch_fs will point to openupgrade_scripts' file which most likely
93+
won't exist when the migrated database is deployed, which breaks resetting views
94+
"""
95+
if "install_filename" in self._context:
96+
path_info = get_resource_from_path(self._context["install_filename"])
97+
if path_info[0] == "openupgrade_scripts":
98+
self = self.with_context(
99+
{k: v for k, v in self._context.items() if k != "install_filename"}
100+
)
101+
return _inverse_arch._original_method(self)
102+
103+
88104
_check_xml._original_method = View._check_xml
89105
View._check_xml = _check_xml
90106
check._original_method = NameManager.check
@@ -93,3 +109,5 @@ def _check_field_paths(self, node, field_paths, model_name, use):
93109
View._raise_view_error = _raise_view_error
94110
_check_field_paths._original_method = View._check_field_paths
95111
View._check_field_paths = _check_field_paths
112+
_inverse_arch._original_method = View._inverse_arch
113+
View._inverse_arch = _inverse_arch
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from odoo.tests import TransactionCase
2+
3+
from odoo.addons.openupgrade_framework import openupgrade_test
4+
5+
6+
@openupgrade_test
7+
class TestArchFs(TransactionCase):
8+
def test_arch_fs(self):
9+
"""
10+
Test that we didn't overwrite arch_fs with the path to the
11+
noupdate changes file
12+
"""
13+
self.assertNotIn(
14+
"openupgrade_scripts",
15+
self.env.ref("hr_recruitment.candidate_hired_template").arch_fs,
16+
)

0 commit comments

Comments
 (0)