Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1098 Lượt xem

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>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

<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)) "/>

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
475
3
thg 8 25
634
3
thg 8 25
1820
1
thg 7 25
800
0
thg 8 25
636