forked from alaguraj/odoo-testing-addons
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
|
|
print("--- STARTING FIX SCRIPT ---")
|
|
try:
|
|
# In odoo shell, 'env' is available.
|
|
# Find active website (or first one)
|
|
websites = env['website'].search([])
|
|
for w in websites:
|
|
print(f"Checking website: {w.name} (ID: {w.id})")
|
|
|
|
# Check for COW view for this website
|
|
homepage_key = 'website.homepage'
|
|
cow_views = env['ir.ui.view'].search([
|
|
('key', '=', homepage_key),
|
|
('website_id', '=', w.id)
|
|
])
|
|
|
|
if cow_views:
|
|
print(f"Found {len(cow_views)} custom homepage views (COW) for {w.name}. Archiving them...")
|
|
for view in cow_views:
|
|
print(f" - Archiving view {view.name} (ID: {view.id})")
|
|
view.write({'active': False})
|
|
else:
|
|
print(f"No custom homepage views found for {w.name}.")
|
|
|
|
# Check theme view logic
|
|
# The theme view should replace website.homepage
|
|
theme_view = env.ref('theme_chennora.custom_homepage', raise_if_not_found=False)
|
|
if theme_view:
|
|
print(f"Theme view found: {theme_view.name} (ID: {theme_view.id}, Priority: {theme_view.priority})")
|
|
# Ensure it's active
|
|
if not theme_view.active:
|
|
theme_view.write({'active': True})
|
|
print(" - Activated theme view")
|
|
|
|
# Ensure priority is high enough to beat default but usually COW is the issue
|
|
if theme_view.priority < 50:
|
|
theme_view.write({'priority': 50})
|
|
print(" - Updated priority to 50")
|
|
else:
|
|
print("WARNING: Theme view 'theme_chennora.custom_homepage' not found! Make sure the module is upgraded.")
|
|
|
|
env.cr.commit()
|
|
print("--- FIX COMPLETE ---")
|
|
except Exception as e:
|
|
print(f"ERROR: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|