Как показать на веб-сайте только те продукты, у которых есть количество в наличии в Odoo 10?

Я новичок в Одоо. Я хочу показывать на веб-сайте электронной коммерции только те продукты, количество которых больше 0. Я использую Odoo 10.

Как я могу это сделать?

Мой код:

<div class="row">
      <div class="hidden" id="products_grid_before"/>
      <div class="col-md-12 col-xs-6" id="products_grid">
        <table width="100%">
          <tbody>
            <tr t-ignore="true">
              <td t-foreach="range(0,rows)" t-as="row" t-attf-width="#{100/rows}%"/>
            </tr>
            <tr t-foreach="bins" t-as="tr_product">
              <t t-foreach="tr_product" t-as="td_product">
                <t t-if="td_product">
                  <t t-set="product" t-value="td_product['product']"/>
                  <td t-att-colspan="td_product['x'] != 1 and td_product['x']" t-att-rowspan="td_product['y'] != 1 and td_product['y']" t-attf-class="oe_product oe_grid oe-height-#{td_product['y']*2} #{ td_product['class'] }">
                    <div class="oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
                      <t t-set="product_image_big" t-value="td_product['x']+td_product['y'] &gt; 2"/>
                      <t t-call="website_sale.products_item"/>
                      <t t-cell="website_sale.products_item"/>
                    </div>
                  </td>
                </t>
                <td t-if="not td_product" class="oe-height-2"/>
              </t>
            </tr>
          </tbody>
        </table>
        <t t-if="not bins">
          <div class="text-center text-muted oe_product">
            <h3 class="css_editable_display">No product defined.</h3>
            <p groups="sales_team.group_sale_manager">Click 
                                <i>'New'</i> in the top-right corner to create your first product.
                            </p>
          </div>
        </t>
      </div>
    </div>
    <div class="products_pager">
      <t t-call="website.pager"/>
    </div>
  </div>

person Taurus Codes    schedule 30.03.2021    source источник


Ответы (1)


Просто добавьте следующий код, где вы показываете свои продукты.

<t t-if="td_product.qty_available >= 0">

    executable statement..

</t>
person Adam Strauss    schedule 30.03.2021
comment
Я пытался, но выдает ошибку, сообщающую об ошибке при компиляции AST AttributeError: объект 'dict' не имеет атрибута 'qty_available' - person Taurus Codes; 01.04.2021
comment
тогда попробуй td_product['qty_available'] - person Adam Strauss; 02.04.2021
comment
проверил, та же ошибка - person Taurus Codes; 04.04.2021
comment
<t t-if="product.qty_available &lt;= 0"> <div class="ribbon-wrapper out-of-stock" style="display: inherit !important;"> <div class="ribbon btn btn-danger">Out of Stock</div> </div> </t> Я пытаюсь это сделать, но это работает только тогда, когда я вхожу в систему как администратор - person Taurus Codes; 05.04.2021