Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2009 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 10 24
7649
3
thg 9 24
6009
3
thg 9 24
3614
1
thg 9 24
1986
0
thg 12 24
1707