Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1919 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
paź 24
7487
3
wrz 24
5265
3
wrz 24
3462
1
wrz 24
1898
0
gru 24
1627