odoo-8odoo-website

How to load the data from odoo to a front end website in odoo8?


I want a sample code for loading the data from odoo to a front end website. For example I want to load the customer name in front end website in Odoo 8.


Solution

    1. Create the controller
    2. Fetch the record on controller using request.env['res.partner'].sudo().search([('customer','=',True)])
    3. Render the result on the template

      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
          })
      

    Here

    1. mymodule is the module name.
    2. customerlist is the template name .
    3. { 'customers': customers } is the dictionary which contain list of object of res.partner
    4. /my/customers/ is url on which you will get the template filled with the customer data

    You can also read the list of resources at

    1. how to accessing the data in odoo website
    2. how to building eCommerce-web-application in ODOO

    Hope it may help in your case.