تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
1940 أدوات العرض

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أكتوبر 24
7518
3
سبتمبر 24
5378
3
سبتمبر 24
3495
1
سبتمبر 24
1919
0
ديسمبر 24
1651