Do you have an example of how to pass a value from a controller to an OWL template? I haven't found a single article discussing this.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
For passing the value from the controller to the template, try to use the following code:
Python:# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
class ExampleController(http.Controller):
@http.route('/example', auth='public', website=True)
def example(self):
message = "Hello, World!"
return request.render('your_module.example_template', {'message': message})
XML:
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="example_template" name="Example Template">
<t t-call="website.layout">
<div id="wrap">
<div class="container">
<h1 t-esc="message"/>
</div>
</div>
</t>
</template>
</odoo>
Hope it helps.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 6 24
|
1519 | ||
|
2
thg 7 25
|
505 | ||
|
0
thg 1 25
|
919 | ||
|
0
thg 12 24
|
1699 | ||
|
0
thg 9 24
|
931 |