Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
2012 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää

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

Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
lokak. 24
7655
3
syysk. 24
6088
3
syysk. 24
3623
1
syysk. 24
1992
0
jouluk. 24
1707