res_config.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request
  3. _MODEL = 'res.config.settings'
  4. '''
  5. '''
  6. def get_pos_config():
  7. config = request.env[_MODEL].search([], limit=1, order='id desc')
  8. return {
  9. 'imageType': config.image_type,
  10. 'allowCurrencyExchange': config.allow_currency_exchange,
  11. 'viewCurrencyExchanges': config.view_currency_exchanges,
  12. 'currencies': [
  13. {
  14. 'id': currency.id,
  15. 'name': currency.display_name,
  16. 'symbol': currency.symbol,
  17. 'position': currency.position,
  18. 'rateSilent': currency.rate_silent,
  19. 'decimalSeparator': currency.decimal_separator,
  20. 'decimalPlaces': currency.decimal_places,
  21. 'thousandsSeparator': currency.thousands_separator
  22. } for currency in config.currency_ids
  23. ]
  24. }
  25. '''
  26. '''
  27. def save_pos_config(**kw):
  28. values = {}
  29. if kw.get('setting') == 'imageType':
  30. values['image_type'] = ('big', 'small')[kw.get('value', False)]
  31. if kw.get('setting') == 'allowCurrencyExchange':
  32. values['allow_currency_exchange'] = kw.get('value', False)
  33. if kw.get('setting') == 'viewCurrencyExchanges':
  34. values['view_currency_exchanges'] = kw.get('value', False)
  35. settings = request.env[_MODEL].search([], limit=1, order='id desc')
  36. settings.write(values)
  37. settings.execute()
  38. return get_pos_config()