【问题标题】:How to show price of product on non shop page如何在非商店页面上显示产品价格
【发布时间】: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没有设置?

我应该打电话给&lt;t t-call="website_sale"/&gt; 或类似的电话吗?

感谢您的帮助!

编辑

在其他产品页面上,类 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>

但这仍然不起作用。有什么帮助吗?

【问题讨论】:

    标签: product odoo qweb odoo-12


    【解决方案1】:

    “非商店”页面是什么意思?没有模板? 那么据我所知,你不能使用 qweb 语言。

    使用类似的东西怎么样:

    <field name="product.price" ... />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-02
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 2018-11-13
      • 2017-06-24
      • 1970-01-01
      相关资源
      最近更新 更多