odoo_website_add_snippet
Insert a website snippet into an Odoo HTML field at a chosen position with optional text, attribute, or image substitutions.
Instructions
Insert a snippet into a target HTML field. Fetches the snippet template from ir.ui.view by key, extracts its root HTML element, applies optional substitutions (text/attr/src changes before insertion), and places it at the specified position relative to an anchor. Positions: 'end' (after last element), 'begin' (before first), 'after' (after anchor_xpath), 'before' (before anchor_xpath), 'replace' (replace anchor_xpath). Substitutions format: {'relative_xpath': value} for text; {'relative_xpath/@attr': value} for attribute; {'relative_xpath/@style:background-image': 'url(...)'} for CSS property; {'relative_xpath/@src': 'https://...'} for image URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | default | |
| model | Yes | ||
| res_id | Yes | ||
| field_name | Yes | ||
| snippet_key | Yes | Snippet template key (e.g. 'website.s_text_block', 'website.s_cta_card') | |
| position | No | end | |
| anchor_xpath | No | Required for position in (after, before, replace). Xpath to the anchor element in target. | |
| substitutions | No | Map of relative xpath → value for pre-insertion customisation. | |
| lang | No | Lang context for write (default: en_US) | |
| dry_run | No |