Hi everyone,
I'm working on Odoo 18 and trying to add a custom field to the SEO modal popup that appears when editing a page on the website (the “Website > Optimize SEO” dialog). I want to include a field called webpage_schema_type to let users pick the Schema.org type for the current page (like WebPage, ContactPage, etc.).
I managed to create the field on the model and make it available, but I can't figure out how to inject it into the modal form UI. The modal is built using OWL components, and I couldn't find an easy way to extend or patch it.
Here’s what I tried:
1. Field on the model:
from odoo import models, fields
class WebsitePage(models.Model):
_inherit = 'website.page'
webpage_schema_type = fields.Selection([
('WebPage', 'WebPage'),
('AboutPage', 'About Page'),
('CheckoutPage', 'Checkout Page'),
('CollectionPage', 'Collection Page'),
('ContactPage', 'Contact Page'),
('FAQPage', 'FAQ Page'),
('ProfilePage', 'Profile Page'),
('SearchResultsPage', 'Search Results Page'),
], string="WebPage Schema Markup", default="WebPage", help="Select Schema Markup for your page. Search engines use structured data to display rich results in SERPs. For more information, visit https://schema.org/WebPage")
2. Trying to patch the modal component (JS):
// In website.assets_editor
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { SeoDialog } from "@website/js/components/dialog/seo";
patch(SeoDialog.prototype, {
setup() {
this._super(...arguments);
this.state.webpage_schema_type = this.props.values.webpage_schema_type || "";
},
});
But nothing appears in the modal.
What I need:
- How to properly extend or patch the SEO modal form to show and save my custom field?
- Do I need to replace the whole component, or is there a cleaner way to inject just one new field?
Any help or example would be appreciated 🙏. I'm open to OWL/JS code if needed. Thanks in advance!