コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
1986 ビュー

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
7590
3
9月 24
5604
3
9月 24
3547
1
9月 24
1956
0
12月 24
1683