콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4871 화면

odoo 10

I'm new in this... I'm having problem to render to my page created on controller

I'm having this error

View 'products.index' in website 1 not found

template.xml

<odoo>
<template id="index_assets_frontend_view">
<t t-foreach="product" t-as="products">
<strong><t t-esc="product.id" /></strong>
<b><t t-esc="product.name" /></b>
</t>
</template>
</odoo>

controller.py

cimport logging
from openerp import SUPERUSER_ID
from openerp import http
from openerp.http import request
from openerp import models, api

class website_qty(http.Controller):

@http.route(['/productos'], auth="public")
def index(self, **post):
arr = []
products = request.env['product.product']
arr = products.search([])
print arr
# return request.render('website.layout',{'products':products.search([])})
return request.render('products.index')
아바타
취소
베스트 답변

You have some errors in your code.

View:

You want to loop (foreach) over all the products, with the name of each product as product.
See changes is bold:

<odoo>
<template id="index">
<t t-foreach="products" t-as="product">
<strong><t t-esc="product.id" /></strong>
<b><t t-esc="product.name" /></b>
</t>
</template>
</odoo>

Controller:

- You have to request the template with its full ID. 
- You don't have to import models and api. Just request the env with http.

Try : (Substitute "nameOfYourModule" with the actual name of your module ;) )

from openerp import http
class website_qty(http.Controller)      @http.route('/productos/', auth='public')
     def index(self, **kw):
        Products = http.request.env['product.product']         return http.request.render('nameOfYourModule.index', {
            'products': Products.search([])
        })
아바타
취소
작성자

thank u so much

작성자 베스트 답변

 

아바타
취소
관련 게시물 답글 화면 활동
0
2월 23
3475
1
3월 19
3480
3
4월 25
2097
2
1월 25
3200
4
6월 24
7726