【问题标题】:How to load the data from odoo to a front end website in odoo8?如何将数据从odoo加载到odoo8中的前端网站?
【发布时间】:2016-06-06 06:34:09
【问题描述】:

我想要一个用于将数据从 odoo 加载到前端网站的示例代码。 例如,我想在 Odoo 8 的前端网站中加载客户名称。

【问题讨论】:

    标签: odoo-8 odoo-website


    【解决方案1】:
    1. 创建控制器
    2. 使用request.env['res.partner'].sudo().search([('customer','=',True)])获取控制器上的记录
    3. 在模板上渲染结果

      class MyController(http.Controller):
      @http.route('/my/customers/', auth='public')
      def my_customers(self, **kw):
          customers = request.env['res.partner'].sudo().search([('customer','=',True)])
          return http.request.render('mymodule.customerlist', {
              'customers': customers
          })
      

    这里

    1. mymodule 是模块名称。
    2. customerlist 是模板名称。
    3. { '客户':客户 } 是包含 res.partner
    4. 对象列表的字典
    5. /my/customers/ 是您将在其上获取填充了客户数据的模板的 URL

    您也可以在

    处阅读资源列表
    1. how to accessing the data in odoo website
    2. how to building eCommerce-web-application in ODOO

    希望对您的情况有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 2019-06-30
      相关资源
      最近更新 更多