Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
2044 Ansichten

Hello,

I want to include a count for the number of lines present in my table (include products, sections, notes).

How can I achieve that?

Avatar
Verwerfen
Beste Antwort

Hi,
If you need the information inside a report template, you can just add this line of code in the needed place:  len(doc.order_line)

Thanks

Avatar
Verwerfen

<t t-esc="len(doc.order_line)"/>

Beste Antwort

Hi,

from odoo import models, fields, api
class SaleOrder(models.Model):
    _inherit = 'sale.order'

    line_count = fields.Integer(string='Number of Lines',
                                compute='_compute_line_count')

    def _compute_line_count(self):
        for order in self:
            order.line_count = len(order.order_line)

the order_line length includes the section and note values 


Hope it helps

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
3
Okt. 24
7709
3
Sept. 24
6305
3
Sept. 24
3682
1
Sept. 24
2017
0
Dez. 24
1722