Skip to Content
मेन्यू
This question has been flagged
2 Replies
2105 Views

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
Discard
Best Answer

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
Discard

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

Best Answer

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
Discard
Related Posts Replies Views Activity
3
अक्तू॰ 24
7957
3
सित॰ 24
6987
3
सित॰ 24
3910
1
सित॰ 24
2130
0
दिस॰ 24
1804