'Returns move lines formatted for the manual/bank reconciliation widget
:param target_currency: currency (browse_record or ID) you want the move line debit/credit converted into
:param target_date: date to use for the monetary conversion'

@api.multi
def prepare_move_lines_for_reconciliation_widget(self, target_currency=False, target_date=False):

    context = dict((self._context or {}))
    ret = []
    if target_currency:
        target_currency = self.env['res.currency'].browse(int(target_currency))
    for line in self:
        company_currency = line.account_id.company_id.currency_id
        ret_line = {'id': line.id, 'name': (((line.name != '/') and ((line.move_id.name + ':    ') + line.name)) or line.move_id.name), 'ref': (line.move_id.ref or ''), 'already_paid': (line.account_id.internal_type == 'liquidity'), 'account_code': line.account_id.code, 'account_name': line.account_id.name, 'account_type': line.account_id.internal_type, 'date_maturity': line.date_maturity, 'date': line.date, 'journal_name': line.journal_id.name, '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:
            total_amount = abs((debit - credit))
            actual_debit = (((debit > 0) and amount) or 0.0)
            actual_credit = (((credit > 0) and (- amount)) or 0.0)
            currency = company_currency
        if (line_currency != target_currency):
            amount_currency_str = formatLang(self.env, abs((actual_debit or actual_credit)), currency_obj=line_currency)
            total_amount_currency_str = formatLang(self.env, total_amount, currency_obj=line_currency)
        if (currency != target_currency):
            ctx = context.copy()
            ctx.update({'date': (target_date or line.date)})
            total_amount = currency.with_context(ctx).compute(total_amount, target_currency)
            actual_debit = currency.with_context(ctx).compute(actual_debit, target_currency)
            actual_credit = currency.with_context(ctx).compute(actual_credit, target_currency)
        amount_str = formatLang(self.env, abs((actual_debit or actual_credit)), currency_obj=target_currency)
        total_amount_str = formatLang(self.env, total_amount, currency_obj=target_currency)
        ret_line['debit'] = abs(actual_debit)
        ret_line['credit'] = abs(actual_credit)
        ret_line['amount_str'] = amount_str
        ret_line['total_amount_str'] = total_amount_str
        ret_line['amount_currency_str'] = amount_currency_str
        ret_line['total_amount_currency_str'] = total_amount_currency_str
        ret.append(ret_line)
    return ret
