如何在网站模块中显示我的数据库文章?

时间:2017-04-12 08:54:04

标签: python web openerp erp odoo-10

我正在使用Odoo 10,我有很多按类别分类的文章,我已经安装了网站模块,现在我想在我的网站的一个页面中显示我的文章和类别

1 个答案:

答案 0 :(得分:2)

要构建网站页面,您可以阅读此处的文档[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,
        })

Seconde步骤是模板视图的创建。喜欢这个

<template id="index">
    <title>Products</title>
    <t t-foreach="products" t-as="product">
      <p><t t-esc="product.name"/></p>
    </t>
</template>

这是一个简单的例子。如果您想了解更多信息,可以阅读文档并查看odoo代码中的示例。

相关问题