Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2045 มุมมอง

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?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง

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

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Accounting - Profit and Loss by Month แก้ไขแล้ว
3
ต.ค. 24
7718
3
ก.ย. 24
6359
3
ก.ย. 24
3695
1
ก.ย. 24
2027
0
ธ.ค. 24
1728