跳至内容
菜单
此问题已终结
2 回复
1913 查看

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
7477
3
9月 24
5243
3
9月 24
3437
1
9月 24
1892
0
12月 24
1622