跳至内容
菜单
此问题已终结
2 回复
618 查看

In the MRP Module's Production Order Report, I need to display the total of all components measured in grams. If necessary, an additional calculated studio field can be used in the form view. Any suggestions are appreciated.

Sharing parts of the components lines within the report

<t t-name="mrp.report_mrp_production_components">

    <table class="table table-sm">

        <div class="oe_structure"/>

        <t t-set="has_product_barcode" t-value="any(m.product_id.barcode for m in o.move_raw_ids)"/>

        <t t-set="i" t-value="1"/>

        <thead>

            <tr style="font-size: 0.9rem; font-weight: bold">

                <th style="font-weight: bold;">Nº</th>

                <th style="font-weight: bold;">Ingredientes</th>

                <th style="font-weight: bold;">Nº Lote</th>

                <th style="font-weight: bold;">Fecha Caducidad</th>

                <th style="font-weight: bold;" t-attf-class="{{ 'text-end' if not has_product_barcode else '' }}">Candidad (g)</th>

                <th style="font-weight: bold;" t-if="has_product_barcode" width="15%" class="text-center">Barcode</th>

            </tr>

        </thead>

        <tbody>

            <tr style="height: 28.4px;font-size: 0.9rem;" t-foreach="o.move_raw_ids" t-as="raw_line">

                <td>

                    <strong t-esc="i"/>

                    <t t-set="i" t-value="i+1"/>

                </td>

                <td>

                    <span t-field="raw_line.product_id">8 GB RAM</span>

                </td>

                <td>

                    <span t-field="raw_line.lot_ids" t-field-options="{'widget': 'many2many_tags'}"/>

                </td>

                <td>

                    <span t-field="raw_line.lot_ids.expiration_date" t-options="{'format': 'dd/MM/yyyy'}"/>

                </td>

                <td t-attf-class="{{ 'text-end' if not has_product_barcode else '' }}">

                    <span t-field="raw_line.product_uom_qty">25</span>

                    <span t-field="raw_line.product_uom" groups="uom.group_uom">Pieces</span>

                </td>

                <td t-if="has_product_barcode" width="15%" class="text-center">

                    <t t-if="raw_line.product_id.barcode">

                        <span t-field="raw_line.product_id.barcode" t-options="{'widget': 'barcode', 'width': 600, 'height': 100, 'img_style': 'width:100%;height:35px'}">12345678901</span>

                    </t>

                </td>

            </tr>

        </tbody>

形象
丢弃
最佳答案

<t t-set="total_weight_grams" t-value="sum(o.move_raw_ids.mapped(lambda x: (x.product_id.weight * x.product_uom_qty) * 1000)) "/>

形象
丢弃
编写者 最佳答案

Thank you so much, it is working more than fine.

形象
丢弃
相关帖文 回复 查看 活动
2
5月 25
640
1
5月 25
221
0
4月 25
567
1
4月 25
565
1
1月 25
771