res_currency.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from openerp import api, fields, models
  2. class ResCurrency(models.Model):
  3. _inherit = 'res.currency'
  4. @api.model
  5. def get_currencies(self):
  6. domain = [('active', '=', True)]
  7. currencies = []
  8. # if self.env.user.store_id:
  9. # domain.append(('company_id', '=', self.env.user.store_id.company_id.id))
  10. # else:
  11. # domain.append(('company_id', '=', self.env.user.company_id.id))
  12. # print domain
  13. for currency in self.env['res.currency'].search(domain):
  14. currencies.append({
  15. 'id': currency.id,
  16. 'name': currency.name,
  17. 'display_name': currency.display_name,
  18. 'accuracy': currency.accuracy,
  19. 'base': currency.base,
  20. 'position': currency.position,
  21. 'rate': currency.rate,
  22. 'rounding': currency.rounding,
  23. 'symbol': currency.symbol,
  24. 'company': {
  25. 'id': currency.company_id.id,
  26. 'name': currency.company_id.name
  27. }
  28. })
  29. return currencies