代码之家  ›  专栏  ›  技术社区  ›  Dhouha

如何在报表中显示产品变型?

  •  0
  • Dhouha  · 技术社区  · 6 年前

    我已经为销售订单报表创建了一个自定义模块。在我的例子中,项目具有多个值的属性,例如color:red,blue。我想在文章描述中显示变量的值。我尝试了几个代码,但我没有得到正确的结果,或者它显示了一个属性的所有值。有什么想法帮助请?

      <?xml version="1.0" encoding="utf-8"?>
     <openerp>
         <data> ...
         <table class="table table-condensed" style="margin-top:25px;">
                        <thead>
                            <tr>
                                <th>N°</th>
                                <th>REFERENCE</th>
                                <th>DESCRIPTION</th>
                                <th class="text-left">QTE</th>
                                <th class="text-left">PRIX UHT</th>
                                <th t-if="display_discount" class="text-left"
                                    groups="sale.group_discount_per_so_line">
                                    REMISE (%)
                                </th>
                                <th>TOTAL NET HT</th>
                                <th class="text-left">TVA</th>
                          </tr>
                        </thead>
                        <tbody class="sale_tbody">
                            <t t-foreach="doc.order_line" t-as="l">
                                <tr t-if="l.product_uom_qty">
                                    <td>
                                        <span t-esc="str(l_index+1)"/>
                                    </td>
                                    <td>
                                        <span t-field="l.product_id.default_code"/>
                                    </td>
                                                <span t-field="value.name"/>
                            <td style="width:50%;">
                                        [<span t-field="l.product_id.name"/>]
                                        <br/>
                                        <t t-foreach="l.product_id.attribute_line_ids" t-as="variant">
                                             <!-- - -->
                                            <strong><span t-field="variant.attribute_id"/>:
                                            </strong>
                                            <t t-foreach="variant.value_ids" t-as="value">
                                            <!--<span t-field="variant.value_ids.name"/>-->
                                                <span t-field="value.name"/>
                                            <!--<br/>-->
                                            </t>
                                        </t>
                                        <span t-field="l.product_id.description_sale"/>
          <td class="text-left" style="width:7%;">
                                        <span t-esc="'%.f'%(l.product_uom_qty)"/>
                                        <!--<span groups="product.group_uom" t-field="l.product_uom"/>-->
                                    </td>
                                    <td class="text-left" style="width:12%;">
                                        <span t-field="l.price_unit"/>
                                    </td>
                                    <td t-if="display_discount" class="text-left"
                                        groups="sale.group_discount_per_so_line" style="width:11%;">
                                        <span t-esc="'%.f'%(l.discount)"/>
                                    </td>
                                    <td style="width:15%;">
                                        <span t-field="l.price_subtotal"/>
                                    </td>
    
                                    <td class="text-left" style="width:9%">
                                        <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_id))"/>
                                    </td>
                                </tr>
                            </t>
                        </tbody>
                    </table>
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   aekis.dev    6 年前