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

I want to add row number in t-foreach table in reports. How can I achieve this ?

Thanks.

アバター
破棄
著作者 最善の回答

Solved with report override and update localcontext with line_no function.

Thanks.

 

アバター
破棄

Can you provide an example? I'm trying to add line numbers to sales order prints.

最善の回答

Hi, I was just adding ordinal numbers on sales reports and stumbled upon this - here is solution - just create computational custom field. Put this in your py file

classOrdinalNumberSales(models.Model): _inherit = 'sale.order.line'
ordinal_number = fields.Integer(compute='_compute_get_number', store=True)
@api.depends('sequence', 'order_id', 'ordinal_number', 'order_id.order_line')def_compute_get_number(self):for rec inself: rec.ordinal_number = False ordinal_number = 1for line in rec.order_id.order_line.filtered(lambdal: not l.display_type): line.ordinal_number = ordinal_number ordinal_number += 1

Now you can call the field in your sale order using line.ordinal_number

アバター
破棄
関連投稿 返信 ビュー 活動
2
1月 25
9696
1
3月 15
10854
1
3月 15
4627
4
1月 25
44670
0
10月 24
1500