Element '<t name="Sort-by Template" t-name="website_sale.sort">' cannot be located in parent view
View error context:
{'file': '/home/developer/Documents/odoo_16/Odoo/addons/website_sale/views/templates.xml',
'line': 1,
'name': 'Sort-by Template',
'view': ir.ui.view(1868,),
'view.model': False,
'view.parent': ir.ui.view(1866,),
'xmlid': 'products'}
尝试从数据库中删除这些记录,但是得到另一个错误。
这只是意味着,在当前版本(v12?)中,您已经创建了一个新视图(ir.ui.view(1868,)),该继承了当前版本中存在xpath-hook的PARENT-View (inherit_id="website_sale.sort"),但在目标版本中不再存在:Odoo v16。
要准确地解决这个问题,您可以将xpath-hook替换为Odoo v16中父视图中存在的xpath-hook(通过检查其xml内容)。
为了快速解决这个问题,您可以停用或删除您的视图(id=1868)。
我的快速修复是使用premigrate .py文件到我的自定义模块之一:my_custom_module/migrations/16.0.0.0.0/premigrate .py其中包含我需要执行的Sql查询,以纠正upgrade-log-Error:
def migrate(cr, version):
# TO CORRECT UPGRADE ERROR 1 : Element '<xpath expr="//xxxx">
# in ir.ui.view(1868,)' cannot be located in parent view
cr.execute("""
update ir_ui_view v
set inherit_id = NULL, mode='primary', active = false
where
v.id in (1868)
""")
或者,在多个继承子视图的情况下,您可以同时处理来自parent_id=1866的所有继承视图
def migrate(cr, version):
# TO CORRECT UPGRADE ERROR 1 : Element '<xpath expr="//xxxx">' cannot be located
# in parent view 'view.parent': ir.ui.view(1866,),
cr.execute("""
update ir_ui_view v
set inherit_id = NULL, mode='primary', active = false
where
v.inherit_id in (1866)
""")