【发布时间】:2019-09-05 10:54:55
【问题描述】:
我想在非商店页面上为用户显示所有可用产品的价格。
如果我查看商店页面上产品展示的代码,它会给我这一行:
<span t-if="product.price" t-esc="product.price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
在我的其他页面上,我使用此代码调用我的产品:
<t t-set="products" t-value="request.env['product.template'].search([])"/>
<t t-foreach="products" t-as="product_template">
<span t-if="product_template.price" t-esc="product_template.price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
</t>
这不显示产品价格。如果我删除t-if="product_template.price",它会显示0.00 $。所以product_template.price没有设置?
我应该打电话给<t t-call="website_sale"/> 或类似的电话吗?
感谢您的帮助!
编辑:
在其他产品页面上,类 js_sale oe_website_sale oe_product oe_product_price oe_price_h4 被调用。所以我试过这个:
<div id="wrap" class="js_sale">
<div class="oe_website_sale">
<t t-set="products" t-value="request.env['product.product'].search([['id', '=', 135]])"/>
<div t-foreach="products" t-as="product" class="oe_product oe_grid">
<div class="oe_product_price product_price">
<h4 class="oe_price_h4">
<span t-esc="product.price"/>
</h4>
</div>
</div>
</div>
</div>
但这仍然不起作用。有什么帮助吗?
【问题讨论】: