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

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 25
9674
1
มี.ค. 15
10841
1
มี.ค. 15
4611
4
ม.ค. 25
44636
0
ต.ค. 24
1479