بنقرة واحدة
odoo-controllers
Create HTTP endpoints for Websites and APIs.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Create HTTP endpoints for Websites and APIs.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
A router skill that identifies and recommends the most appropriate Odoo skill for a given user request.
Comprehensive guide to Odoo fields, including basic, relational, computed, and robust technical features (indexing, company_dependent, properties).
Master the Odoo ORM for data manipulation, environment management, and CRUD operations.
Configure Access Control Lists (ACLs) using CSV files.
Write automated tests using TransactionCase and Form emulators to ensure code quality.
Define List, Form, and Search views in XML.
| name | Odoo Controllers |
| description | Create HTTP endpoints for Websites and APIs. |
Handle HTTP requests in Odoo to build website pages or JSON APIs.
Controllers are defined in the controllers/ directory of your module.
my_module/
├── controllers/
│ ├── __init__.py
│ └── main.py
Don't forget to import controllers in your module's top-level __init__.py.
Inherit from odoo.http.Controller.
from odoo import http
from odoo.http import request
class EstateController(http.Controller):
@http.route('/estate/hello', auth='public', type='http')
def hello(self, **kwargs):
return "Hello, World!"
@route Decoratorroute: The URL path (e.g., /my/url).type:
'http': Standard web request. Returns HTML strings or rendered templates.'json': JSON-RPC request. Returns a Python dictionary (automatically serialized to JSON).auth:
'public': Accessible by anyone (even not logged in).'user': Restricted to logged-in users.'none': Very low-level (no database cursor/user). Rarely used.methods: List of HTTP methods (e.g., ['POST', 'GET']). Default is all.cors: CORS headers (e.g., '*').request Objectrequest.env: Access the ORM environment (if auth='user' or public).request.params: Dictionary of query parameters (GET) and body parameters (POST).request.httprequest: The underlying Werkzeug request object.Use request.render(template_xml_id, values):
@http.route('/estate/properties', auth='public', website=True)
def list_properties(self, **kw):
properties = request.env['estate.property'].search([])
return request.render('estate.property_list_template', {
'properties': properties
})
website=True: Adds website context (menus, footer, user session).@http.route('/estate/api/properties', auth='public', type='json', methods=['POST'])
def api_properties(self):
properties = request.env['estate.property'].search([])
return [
{'name': p.name, 'price': p.expected_price}
for p in properties
]
Inherit the controller and redefine the method with the same name.
from odoo.addons.website_sale.controllers.main import WebsiteSale
class WebsiteSaleInherit(WebsiteSale):
@http.route()
def shop(self, page=0, category=None, search='', ppg=False, **post):
# Do something before
response = super().shop(page, category, search, ppg, **post)
# Do something after
return response