Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
1982 Vues

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
Ignorer
Meilleure réponse

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
Ignorer

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

Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
3
oct. 24
7587
3
sept. 24
5598
3
sept. 24
3545
1
sept. 24
1955
0
déc. 24
1681