跳至內容
選單
此問題已被標幟
2 回覆
1956 瀏覽次數

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
10月 24
7533
3
9月 24
5417
3
9月 24
3503
1
9月 24
1924
0
12月 24
1656