【发布时间】:2017-04-12 08:54:03
【问题描述】:
我正在使用 Odoo 10,我有很多按类别分类的文章,并且我已经安装了网站模块,现在我想在我网站的一个页面中显示我的文章和类别
【问题讨论】:
-
您好,欢迎来到 StackOverflow!请考虑使用the tour 来改善您的问题 - 从而提高获得答案的可能性!
标签: python web openerp erp odoo-10
我正在使用 Odoo 10,我有很多按类别分类的文章,并且我已经安装了网站模块,现在我想在我网站的一个页面中显示我的文章和类别
【问题讨论】:
标签: python web openerp erp odoo-10
要构建网站页面,您可以在此处阅读文档 [https://www.odoo.com/documentation/10.0/howtos/website.html][1]
继续你必须做的事情。
第一步是创建与控制器的链接。像这样
from odoo import http
class Product(http.Controller):
@http.route('/products/', auth='public')
def index(self, **kw):
product_ids = self.env['product.product'].search([])
return http.request.render('academy.index', {
'products': product_ids,
})
第二步是创建模板视图。像这样
<template id="index">
<title>Products</title>
<t t-foreach="products" t-as="product">
<p><t t-esc="product.name"/></p>
</t>
</template>
这是一个简单的例子。如果您想了解更多信息,可以阅读文档并查看 odoo 代码中的示例。
【讨论】: