'This function prepares the value to use for the creation of the default debit and credit accounts of a
liquidity journal (created through the wizard of generating COA from templates for example).
:param name: name of the bank account
:param company: company for which the wizard is running
:param currency_id: ID of the currency in wich is the bank account
:param type: either \'cash\' or \'bank\'
:return: mapping of field names and values
:rtype: dict'

@api.model
def _prepare_liquidity_account(self, name, company, currency_id, type):

    code_digits = (company.accounts_code_digits or 0)
    if (type == 'bank'):
        account_code_prefix = (company.bank_account_code_prefix or '')
    else:
        account_code_prefix = (company.cash_account_code_prefix or company.bank_account_code_prefix or '')
    for num in xrange(1, 100):
        new_code = (str(account_code_prefix.ljust((code_digits - 1), '0')) + str(num))
        rec = self.env['account.account'].search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1)
        if (not rec):
            break
    else:
        raise UserError(_('Cannot    generate    an    unused    account    code.'))
    liquidity_type = self.env.ref('account.data_account_type_liquidity')
    return {'name': name, 'currency_id': (currency_id or False), 'code': new_code, 'user_type_id': ((liquidity_type and liquidity_type.id) or False), 'company_id': company.id}
