Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
1957 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona

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

Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
ott 24
7535
3
set 24
5432
3
set 24
3506
1
set 24
1925
0
dic 24
1656