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
""" Used to validate a batch of reconciliations in a single call
            :param data: list of dicts containing:
                - 'type': either 'partner' or 'account'
                - 'id': id of the affected res.partner or account.account
                - 'mv_line_ids': ids of exisiting account.move.line to reconcile
                - 'new_mv_line_dicts': list of dicts containing values suitable for account_move_line.create()
        """
        for datum in data:
            if len(datum['mv_line_ids']) >= 1 or len(datum['mv_line_ids']) + len(datum['new_mv_line_dicts']) >= 2:
                self.process_reconciliation(cr, uid, datum['mv_line_ids'], datum['new_mv_line_dicts'], context=context)
            if datum['type'] == 'partner':
                partners = self.pool['res.partner'].browse(cr, uid, datum['id'], context=context)
                self.pool['res.partner'].mark_as_reconciled(cr, uid, partners.ids, context=context)
            if datum['type'] == 'account':
                accounts = self.pool['account.account'].browse(cr, uid, datum['id'], context=context)
                self.pool['account.account'].mark_as_reconciled(cr, uid, accounts.ids, context=context)
    @api.multi
    def process_reconciliation(self, new_mv_line_dicts):