Hello everyone, 

why this line is inside the loop?

https://github.com/odoo/odoo/blob/132c7e75e57321c77aac9250a2587c74c5da7857/addons/account/models/account_move.py#L1364

We were removing 100k~ account.move.line records for testing purposes. It took ages. So we do some little investigation and saw this, we took out from the loop the process duration became minutes from hours.

Regards from Projet
addons/account/models/account_move.py
'partner_id': line.partner_id.id,
                'partner_name': line.partner_id.name,
                'currency_id': (line.currency_id and line.amount_currency) and line.currency_id.id or False,
            }
            debit = line.debit
            credit = line.credit
            amount = line.amount_residual
            amount_currency = line.amount_residual_currency
            
            if line.account_id.internal_type == 'liquidity':
                amount = abs(debit - credit)
                amount_currency = abs(line.amount_currency)
            
            target_currency = target_currency or company_currency
            line_currency = (line.currency_id and line.amount_currency) and line.currency_id or company_currency
            amount_currency_str = ""
            total_amount_currency_str = ""
            if line_currency != company_currency and target_currency == line_currency:
                
                
                
                
                total_amount = line.amount_currency
                actual_debit = debit > 0 and amount_currency or 0.0
                actual_credit = credit > 0 and -amount_currency or 0.0
                currency = line_currency
            else:
                # Ei
                #  - 
                #  -