Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from odoo import api
from odoo.exceptions import ValidationError
from odoo.modules.module import get_resource_from_path
from odoo.tools import mute_logger

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


def _inverse_arch(self):
"""
Remove install_filename from context if it's from openupgrade_scripts.
Without this, arch_fs will point to openupgrade_scripts' file which most likely
won't exist when the migrated database is deployed, which breaks resetting views
"""
if "install_filename" in self._context:
path_info = get_resource_from_path(self._context["install_filename"])
if path_info[0] == "openupgrade_scripts":
self = self.with_context(
{k: v for k, v in self._context.items() if k != "install_filename"}
)
return _inverse_arch._original_method(self)


_check_xml._original_method = View._check_xml
View._check_xml = _check_xml
check._original_method = NameManager.check
Expand All @@ -93,3 +109,5 @@ def _check_field_paths(self, node, field_paths, model_name, use):
View._raise_view_error = _raise_view_error
_check_field_paths._original_method = View._check_field_paths
View._check_field_paths = _check_field_paths
_inverse_arch._original_method = View._inverse_arch
View._inverse_arch = _inverse_arch
16 changes: 16 additions & 0 deletions openupgrade_scripts/scripts/hr_recruitment/tests/test_arch_fs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo.tests import TransactionCase

from odoo.addons.openupgrade_framework import openupgrade_test


@openupgrade_test
class TestArchFs(TransactionCase):
def test_arch_fs(self):
"""
Test that we didn't overwrite arch_fs with the path to the
noupdate changes file
"""
self.assertNotIn(
"openupgrade_scripts",
self.env.ref("hr_recruitment.candidate_hired_template").arch_fs,
)