Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1102 Переглядів

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.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
серп. 25
476
3
серп. 25
634
3
серп. 25
1820
1
лип. 25
800
0
серп. 25
636