Skip to content

Guide to Remove Legacy Websites from the Odoo Website Module

Note: Before starting this guide, make sure to complete the steps in the Guide to Uninstall E-commerce Modules in Odoo. This ensures that dependent modules and configurations are properly removed, preventing potential issues when cleaning up legacy websites. It is also recommended to review and delete records via the UI when possible, although alternative methods are provided.

Purpose

This guide provides a step-by-step process to safely remove websites that are no longer in use from the Odoo Website module. This cleanup helps simplify the system and supports smoother future upgrades.

⚠️ Important Warning

Never delete website ID 1 ("Community Natural Foods") - this is the main website and must be preserved.


Websites (Initial State)

  • Go to Website → Configuration → Websites

Websites
Image 1 – Initial list of Websites


Pre-Removal Verification

Before starting, verify which websites currently exist in the system:

-- List all websites in the system
SELECT id, name, domain 
FROM website 
ORDER BY id;

Steps to Remove Legacy Websites

1. Archive and Remove Website Content

a. Remove Website References from Blogs

Clear the website association from blogs not tied to the "Community Natural Foods" website:

UPDATE blog_blog 
SET website_id = NULL 
WHERE website_id != 1;

b. Archive All Blog Posts

Deactivate all blog posts:

UPDATE blog_post 
SET active = False 
WHERE id > 0;

c. Remove Blog Posts Not Belonging to "Community Natural Foods"

Via UI:

  • Go to Website → Blogs
  • If there are no active posts, check archived ones (Filters/Archived)
  • Select posts not linked to Community Natural Foods
  • Click Action → Delete
  • Repeat until all unnecessary posts are deleted

2-blog-posts.png
Image 2 – Initial list of Blog Posts

Alternatively, use SQL:

DELETE FROM blog_post 
WHERE blog_id != 5;

3-blog-posts-after-deletion.png
Image 3 - Blog Posts after deletion

d. Remove Website Pages (Except Homepage)

Via UI:

  • Navigate to Website → Configuration → Pages
  • Filter by "Website ≠ Community Natural Foods"
  • Select all and delete
  • Also check archived pages with Active = False

4-configuration-pages.png
Image 4 - Configuration → Pages

5-delete-website-pages.png
Image 5 - List of Website Pages

6-website-pages-active-is-false.png
Image 6 - Archived Website Pages

Alternatively, use SQL:

DELETE FROM website_page 
WHERE NOT (url = '/' AND website_id = 1) 
   OR website_id IS NULL;

7-website-pages-after-deletion.png
Image 7 - Website Pages showing the Community Natural Foods website

e. Remove Website from Archived Pricelists

Clear website values from all pricelists not tied to "Community Natural Foods":

UPDATE product_pricelist 
SET website_id = NULL 
WHERE website_id != 1 
   OR website_id IS NULL;

2. Bulk Delete Legacy Websites

Via UI:

  • Go to Website → Configuration → Websites
  • Select websites with IDs 4, 5, 7, 8, 9, 10, 12, 14
  • Click Action → Delete

8-delete-websites-1.png
Image 8 - Websites to delete

Alternatively, use SQL:

DELETE FROM website 
WHERE id IN (4, 5, 7, 8, 9, 10, 12, 14);

9-websites-after-deletion-1.png
Image 9 - List of Websites after deleting websites with ID 4, 5, 7, 8, 9, 10, 12 and 14


3. Special Case: "Order Limit Reached - Home Delivery" (ID: 3)

a. Remove Website from eCommerce Categories

UPDATE product_public_category 
SET website_id = NULL 
WHERE website_id = 3;

b. Delete the Website Record

Via UI: - Delete the website with ID = 3

Alternatively, use SQL:

DELETE FROM website 
WHERE id = 3;


4. Delete Individual Legacy Websites

For each website below, first remove associated references, then delete the website itself via the UI. Alternatively, use the provided SQL queries.

YYC Landing Page (ID: 6)

  • Unlink delivery carriers and coupon programs from Website ID 6

    UPDATE delivery_carrier SET website_id = NULL WHERE website_id = 6;
    UPDATE sale_coupon_program SET website_id = NULL WHERE website_id = 6;
    
  • Via UI:

    ▪ Delete the website with ID = 6

  • Alternatively:

    DELETE FROM website WHERE id = 6;
    

Down for Maintenance - Downtown (ID: 13)

  • Unlink product categories from Website ID 13

    UPDATE product_public_category SET website_id = NULL WHERE website_id = 13;
    
  • Via UI:

    ▪ Delete the website with ID = 13

  • Alternatively:

    DELETE FROM website WHERE id = 13;
    

Down for Maintenance - Home Delivery (ID: 15)

  • Unlink product templates from Website ID 15

    UPDATE product_template SET website_id = NULL WHERE website_id = 15;
    

  • Via UI:

    ▪ Delete the website with ID = 15

  • Alternatively:

    DELETE FROM website WHERE id = 15;
    

National Delivery (ID: 16)

  • Unlink delivery carriers, product categories, and coupon programs from Website ID 16
    UPDATE delivery_carrier SET website_id = NULL WHERE website_id = 16;
    UPDATE product_public_category SET website_id = NULL WHERE website_id = 16;
    UPDATE sale_coupon_program SET website_id = NULL WHERE website_id = 16;
    
  • Via UI:

    ▪ Delete the website with ID = 16

  • Alternatively:

    DELETE FROM website WHERE id = 16;
    

Websites (Final State)

Websites
Image 10 – Final state of Websites after cleanup


Summary Table of Removed Websites

Status Website Name ID Notes
✅ Order Limit Reached - Home Delivery 3 Special case: linked to blogs and product categories
✅ Crowfoot Curbside Pickup 4
✅ Chinook Curbside Pickup 5
✅ YYC Landing Page 6 Required unlinking from shipping methods and coupons
✅ Register Here 7
✅ Order Limit Reached - Crowfoot 8
✅ Order Limit Reached - Chinook 9
✅ Order Limit Reached - Downtown 10
✅ Down for Maintenance - Crowfoot 12
✅ Down for Maintenance - Downtown 13 Unlinked from product categories
✅ Down for Maintenance - Home Delivery 15 Unlinked from product templates
✅ National Delivery 16 Unlinked from multiple models

Rollback Queries (if needed)

In case any deletion must be reverted manually, restore from a backup or reassign websites to records manually. Example rollback queries:

-- Reassign blog_blog to a website
UPDATE blog_blog SET website_id = 1 WHERE id = <blog_id>;

-- Reassign product template
UPDATE product_template SET website_id = 1 WHERE id = <template_id>;

-- Recreate deleted website if needed
INSERT INTO website (id, name, ...) VALUES (...);

Post-Removal Verification

After completing all deletions, run these queries to verify data integrity:

-- Check for orphaned sale orders
SELECT COUNT(*) as orphaned_orders 
FROM sale_order 
WHERE website_id IS NOT NULL 
 AND website_id NOT IN (SELECT id FROM website);

-- Check for orphaned product templates
SELECT COUNT(*) as orphaned_products 
FROM product_template 
WHERE website_id IS NOT NULL 
 AND website_id NOT IN (SELECT id FROM website);

-- Check for orphaned delivery carriers
SELECT COUNT(*) as orphaned_carriers 
FROM delivery_carrier 
WHERE website_id IS NOT NULL 
 AND website_id NOT IN (SELECT id FROM website);

-- Check for orphaned coupon programs
SELECT COUNT(*) as orphaned_coupons 
FROM sale_coupon_program 
WHERE website_id IS NOT NULL 
 AND website_id NOT IN (SELECT id FROM website);

-- Verify only the main website remains
SELECT id, name, domain 
FROM website 
ORDER BY id;

If any orphaned records are found, update them to point to website ID 1 or set to NULL as appropriate.


Final Recommendations

  • Use Developer Mode in Odoo to inspect website dependencies
  • After deletions, validate that remaining websites function correctly
  • Consider adding constraints or validation rules to prevent orphaned records