I have developed custom modules, with their own data, and i wish to present them on the website module. I wish to create a block with it so it is easy to put it out. Sadly i found no material on how to do this.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
To present your custom module data on the Odoo website and create a block for easy integration, you can follow these steps. It involves using Odoo's Website Builder and extending it to display your custom module's data dynamically.
Here’s a step-by-step guide to achieve that:
1. Create a Custom Controller
You need to create a custom controller to fetch your custom module data and pass it to the website template.
Example:
Let's assume your custom module is called my_custom_module and you want to display a list of products or records from this module on your website.
- First, create a Python controller in your custom module. This will handle the request and pass data to the website.
from odoo import http from odoo.http import request class MyCustomModuleController(http.Controller): @http.route('/my_custom_module', auth='public', website=True) def index(self, **kw): # Fetch data from your custom module records = request.env['my.custom.model'].search([]) # Replace with your model name # Render a template with the fetched records return request.render('my_custom_module.template_id', { 'records': records, })
This will create a URL (/my_custom_module) where your custom module data will be displayed.
2. Create a Website Template
Next, you need to create a template in the views folder of your module. This template will display the data passed from the controller.
Example Template (views/website_template.xml):
<odoo> <template id="template_id" name="Custom Module Template"> <div class="custom-module-block"> <h2>My Custom Data</h2> <t t-foreach="records" t-as="record"> <div class="record"> <h3><t t-esc="record.name"/></h3> <!-- Replace with your model's field --> <p><t t-esc="record.description"/></p> <!-- Replace with your model's field --> </div> </t> </div> </template> </odoo>
In this template:
- We're using <t t-foreach="records" t-as="record"> to loop through the records passed from the controller.
- Replace record.name and record.description with the actual fields from your model.
3. Add the Block to the Website
Once the controller and template are set up, you can create a block for this data on your website.
- Go to Website → Pages → Add New Page or edit an existing page.
- In the page editor, you can add your new custom block using Custom HTML or Snippet options.
- In the editor, add the block with a dynamic URL (e.g., /my_custom_module) so it pulls the data from the controller template.
Hey, i think your answer is here: https://www.odoo.com/documentation/18.0/fr/developer/howtos/website_themes/building_blocks.html
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
3
mei 25
|
2819 | ||
|
0
dec. 23
|
2483 | ||
|
1
jul. 23
|
2568 | ||
|
0
jul. 22
|
1989 | ||
Odoo? Why this new name?
Opgelost
|
|
3
sep. 21
|
22207 |