Skip to content

Commit 21d73b8

Browse files
committed
[FIX] don't set install_filename when loading views from openupgrade_scripts
1 parent be146f9 commit 21d73b8

File tree

1 file changed

+18
-0
lines changed
  • openupgrade_framework/odoo_patch/odoo/addons/base/models

1 file changed

+18
-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 IrUiView
@@ -70,9 +71,26 @@ def _check_field_paths(self, node, field_paths, model_name, use):
7071
pass
7172

7273

74+
def _inverse_arch(self):
75+
"""
76+
Remove install_filename from context if it's from openupgrade_scripts.
77+
Without this, arch_fs will point to openupgrade_scripts' file which most likely
78+
won't exist when the migrated database is deployed, which breaks resetting views
79+
"""
80+
if "install_filename" in self.env.context:
81+
path_info = get_resource_from_path(self.env.context["install_filename"])
82+
if path_info[0] == "openupgrade_scripts":
83+
self = self.with_context( # pylint: disable=context-overridden
84+
{k: v for k, v in self.env.context.items() if k != "install_filename"}
85+
)
86+
return _inverse_arch._original_method(self)
87+
88+
7389
_check_xml._original_method = IrUiView._check_xml
7490
IrUiView._check_xml = _check_xml
7591
_raise_view_error._original_method = IrUiView._raise_view_error
7692
IrUiView._raise_view_error = _raise_view_error
7793
_check_field_paths._original_method = IrUiView._check_field_paths
7894
IrUiView._check_field_paths = _check_field_paths
95+
_inverse_arch._original_method = IrUiView._inverse_arch
96+
IrUiView._inverse_arch = _inverse_arch

0 commit comments

Comments
 (0)