Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
1937 Представления

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

Аватар
Отменить
Related Posts Ответы Просмотры Активность
3
окт. 24
7513
3
сент. 24
5358
3
сент. 24
3488
1
сент. 24
1914
0
дек. 24
1636