odoo-testing-addons/debug_view.py

40 lines
1.5 KiB
Python

import logging
from odoo import http, tools, _
from odoo.http import request
def check_render(dbname):
try:
registry = odoo.registry(dbname)
with registry.cursor() as cr:
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
# Try to render the contactus page view
# Typically 'website.contactus' is the template
print("Attempting to render website.contactus...")
try:
view_id = env.ref('website.contactus')
print(f"View ID: {view_id.id}")
# We need a website context
website = env['website'].browse(1)
# Mock request object if needed, or just use context
# Rendering view directly
arch = env['ir.ui.view']._render_template(view_id.id, {'main_object': view_id})
print("Render SUCCESS (length: {})".format(len(arch)))
except Exception as e:
print("Render FAILED:")
import traceback
traceback.print_exc()
print("-" * 20)
print("Checking for broken XPaths specifically on this view inheritance...")
# List inherited views
for inherit in view_id.inherit_children_ids:
print(f"Child View: {inherit.id} {inherit.name} (Active: {inherit.active})")
except Exception as e:
print(f"General failure: {e}")
if __name__ == "__main__":
check_render('FOODIES-DELIGHT')