Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6725 Lượt xem

Hi,

I wrote this code and ask me how to push the value_to_page variable to the QWeb-Template,

that is renderd in the shop function?

In QWeb i need something like <t t-esc="value_to_page" />.


import openerp
from openerp.http import route
from openerp.http import request

class SiteCategories(openerp.addons.website_sale.controllers.main.website_sale):

@route()
def shop(self):
value_to_page = "TEST VALUE"
sup = super(SiteCategories, self).shop()
return sup

Thank you

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I found a solution for myself:

...
@route()
def shop(self):
value_to_page = "TEST VALUE"
sup = super(SiteCategories, self).shop()
#MY SOLUTION START
sup.qcontext["value_to_page"] = value_to_page
#MY SOLUTION END
return sup


Thank you

Ảnh đại diện
Huỷ bỏ

Nice solution. It always bothers me that website_sale controller doesn't use separated functions to build the values dict (it does that way only for checkout page), that would be easier to add values by overloading.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 21
5084
3
thg 5 21
14115
2
thg 7 16
8143
2
thg 8 20
11120
2
thg 8 25
2447