res_currency.py 979 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request
  3. def check_base_currency():
  4. company_currency = request.env.user.company_id.currency_id
  5. other_currencies = request.env['res.currency'].search([('base', '=', True), ('id', '!=', company_currency.id)])
  6. if other_currencies:
  7. for c in other_currencies:
  8. c.write({
  9. 'base': False
  10. })
  11. if not company_currency.base:
  12. company_currency.write({
  13. 'base': True
  14. })
  15. def get_base_currency():
  16. currency = request.env.user.company_id.currency_id
  17. return {
  18. 'id': currency.id,
  19. 'name': currency.display_name,
  20. 'base': currency.base,
  21. 'symbol': currency.symbol,
  22. 'position': currency.position,
  23. 'rateSilent': currency.rate_silent,
  24. 'decimalSeparator': currency.decimal_separator,
  25. 'decimalPlaces': currency.decimal_places,
  26. 'thousandsSeparator': currency.thousands_separator
  27. }