12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- # -*- coding: utf-8 -*-
- from openerp.http import request as r
- def get_currencies_from_journal():
- domain = [
- ('type', 'in', ['bank', 'cash']),
- ('default_debit_account_id.currency_id', '=', False),
- ('active', '=', True)
- ]
- currencies = []
- for j in r.env['account.journal'].search(domain):
- c = j.currency or j.company_id.currency_id
- currencies.append({
- 'id': c.id,
- 'name': c.display_name,
- 'base': c.base,
- 'symbol': c.symbol,
- 'position': c.position,
- 'rateSilent': c.rate_silent,
- 'decimalSeparator': c.decimal_separator,
- 'decimalPlaces': c.decimal_places,
- 'thousandsSeparator': c.thousands_separator
- })
-
- return {c['id']:c for c in currencies}.values()
- def get_journals():
- domain = [
- ('type', 'in', ['bank', 'cash']),
- ('default_debit_account_id.currency_id', '=', False),
- ('active', '=', True)
- ]
- return [{
- 'id': j.id,
- 'name': j.name,
- 'displayName': j.display_name,
- 'code': j.code,
- 'cashControl': j.cash_control,
- 'type': j.type,
- 'currency': {
- 'id': j.currency.id,
- 'name': j.currency.name,
- 'displayName': j.currency.display_name
- },
- 'defaultDebitAccount': {
- 'id': j.default_debit_account_id.id,
- 'name': j.default_debit_account_id.name,
- 'displayName': j.default_debit_account_id.display_name,
- 'code': j.default_debit_account_id.code,
- 'exchange_rate': j.default_credit_account_id.exchange_rate,
- 'foreignBalance': j.default_credit_account_id.foreign_balance,
- 'reconcile': j.default_credit_account_id.reconcile,
- 'debit': j.default_credit_account_id.debit,
- 'credit': j.default_credit_account_id.credit,
- 'currencyMode': j.default_credit_account_id.currency_mode,
- 'companyCurrency': {
- 'id': j.default_credit_account_id.company_currency_id.id,
- 'name': j.default_credit_account_id.company_currency_id.name,
- 'displayName': j.default_credit_account_id.company_currency_id.display_name,
- },
- 'currency': {
- 'id': j.default_credit_account_id.currency_id.id,
- 'name': j.default_credit_account_id.currency_id.name,
- 'displayName': j.default_credit_account_id.currency_id.display_name
- }
- }
- } for j in r.env['account.journal'].search(domain, order='id')]
|