12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- # -*- coding: utf-8 -*-
- from openerp.http import request
- _MODEL = 'res.config.settings'
- def get_pos_config():
- config = request.env[_MODEL].search([], limit=1, order='id desc')
- config = config.get_default_settings([])
- return {
- 'imageType': config.get('image_type'),
- 'allowCurrencyExchange': config.get('allow_currency_exchange'),
- 'viewCurrencyExchanges': config.get('view_currency_exchanges'),
- 'allowChangeUser': config.get('allow_change_user'),
- 'allowChangeDate': config.get('allow_change_date'),
- 'allowPricelist': config.get('allow_pricelist'),
- 'currencies': [
- {
- 'id': currency.id,
- 'name': currency.display_name,
- 'symbol': currency.symbol,
- 'position': currency.position,
- 'rateSilent': currency.rate_silent,
- 'decimalSeparator': currency.decimal_separator,
- 'decimalPlaces': currency.decimal_places,
- 'thousandsSeparator': currency.thousands_separator
- } for currency in request.env['res.currency'].browse(config.get('currency_ids'))
- ]
- }
- def save_pos_config(kw):
- values = {}
-
- if kw.get('setting') == 'imageType':
- values['image_type'] = ('big', 'small')[kw.get('value', False)]
-
- if kw.get('setting') == 'allowCurrencyExchange':
- values['allow_currency_exchange'] = kw.get('value', False)
-
- if kw.get('setting') == 'viewCurrencyExchanges':
- values['view_currency_exchanges'] = kw.get('value', False)
- settings = request.env[_MODEL].search([], limit=1, order='id desc')
- if settings:
- settings.write(values)
- else:
- settings = settings.create(values)
- settings.execute()
-
- return get_pos_config()
-
|