2017-07-27 19 views
2

は私の例です:は自宅にデータをレンダリング(インデックス)私は下記、自宅(インデックス)ページ上のデータをレンダリングするページodoo 9

コントローラ:

import openerp.http as http 
from openerp.http import request 

class TestController(http.Controller): 

    @http.route('/index',auth='public',website=True) 
    def list(self,**kw): 
     Test9 = http.request.env['test.9'] 
     arr = Test9.search([]) 
     print arr 
     return http.request.website.render('website.layout', 
       {'test9':Test9.search([]) 
    }) 

XML

<?xml version="1.0" encoding="utf-8"?> 
<openerp> 
    <data> 
     <template id="test9" name="Test9" page="True"> 
      <t t-call="website.layout"> 
       <div class="oe_structure"> 
        <div class="container"> 
        <center><h3>Details</h3></center> 
        <t t-foreach="test9" t-as="company"> 
         <h4><span t-esc="company.name"/></h4> 
         <table class="table-striped table"> 
         <tr> 
          <td>Name:</td> 
          <td><span t-esc="company.name"/></td> 
         </tr> 
         <tr> 
          <td>City:</td> 
          <td><span t-esc="company.city"/></td> 
         </tr> 
         <tr> 
          <td>Place:</td> 
          <td> 
          <td><span t-esc="company.place"/></td> 
          </td> 
         </tr> 
         </table> 
        </t> 
        </div> 
       </div> 
      </t> 
     </template> 
    </data> 
</openerp> 

実行後http://localhost:8069/indexコンソールで2つのレコードを取得

私のコードで問題はどこですか?

...................................... .................................................. ................................................

答えて

1

お試しください。

import openerp.http as http 
from openerp.http import request 

class List(openerp.addons.web.controllers.main.Home): 

    @http.route('/', type='http', auth='none', website=True) 
    def index(self): 
     Test9 = request.env['test.9'] 
     arr = Test9.search([]) 
     print arr 
     return request.render('YOUR_MODULE.test9', 
      {'test9':Test9.search([]) 
     }) 
+0

http:// localhost:8069/indexでhttp:// localhost:8069 /のデータを返します。どのようにホームページのデータを取得するのですか?これはodooのデフォルト名ですか? –

+0

私はここにデータが必要ですhttp://imgur.com/a/SO6rC –

+0

私の回答を更新します –

関連する問題