Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1991 Переглядів

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
7600
3
вер. 24
5648
3
вер. 24
3554
1
вер. 24
1962
0
груд. 24
1692