res_currency.py 944 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8-*-
  2. from openerp.http import request as r
  3. def check_base_currency():
  4. base_currency = r.env['res.currency'].search([('base', '=', True)])
  5. if not base_currency:
  6. r.env.user.company_id.currency_id.write({
  7. 'base': True
  8. })
  9. def get_currency_id(journal_id):
  10. j = r.env['account.journal'].browse(journal_id)
  11. return j.default_debit_account_id.currency_id.id or j.default_debit_account_id.company_currency_id.id
  12. def get_base_currency():
  13. currency = r.env.user.company_id.currency_id
  14. return {
  15. 'id': currency.id,
  16. 'name': currency.display_name,
  17. 'base': currency.base,
  18. 'symbol': currency.symbol,
  19. 'position': currency.position,
  20. 'rateSilent': currency.rate_silent,
  21. 'decimalSeparator': currency.decimal_separator,
  22. 'decimalPlaces': currency.decimal_places,
  23. 'thousandsSeparator': currency.thousands_separator
  24. }