12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- # -*- coding: utf-8 -*-
- from openerp.http import request
- from res_users import get_current_user
- from res_config import get_pos_config
- _MODEL = 'account.journal'
- '''
- '''
- def get_journals():
- domain = [
- ('type', 'in', ['bank', 'cash']),
- ('active', '=', True)
- ]
- if not get_pos_config().get('allowCurrencyExchange'):
- currency_id = get_current_user().get('company').get('currencyId')
- domain.append('|')
- domain.append(('currency', '=', currency_id))
- domain.append(('company_id.currency_id', '=', currency_id))
- return [
- {
- 'id': journal.id,
- 'name': journal.display_name,
- 'code': journal.code,
- 'type': journal.type,
- 'subtype': journal.subtype or None,
- 'currencyId': journal.currency.id or journal.company_id.currency_id.id
- } for journal in request.env[_MODEL].search(domain, order='id')
- ]
- '''
- '''
- def get_currencies_from_journals():
- domain = [
- ('type', 'in', ['bank', 'cash']),
- ('active', '=', True)
- ]
- currencies = []
- for journal in request.env[_MODEL].search(domain):
- currency = journal.currency or journal.company_id.currency_id
- currencies.append({
- 'id': currency.id,
- 'name': currency.display_name,
- 'base': currency.base,
- 'symbol': currency.symbol,
- 'position': currency.position,
- 'rateSilent': currency.rate_silent,
- 'decimalSeparator': currency.decimal_separator,
- 'decimalPlaces': currency.decimal_places,
- 'thousandsSeparator': currency.thousands_separator
- })
-
- return {c['id']:c for c in currencies}.values()
- '''
- '''
- def get_currency(journal_id):
- journal = request.env['account.journal'].browse(journal_id)
- return journal.default_credit_account_id.currency_id.id or journal.default_credit_account_id.company_currency_id.id
|