res_currency.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ResCurrency(models.Model):
  4. _inherit = 'res.currency'
  5. _name = 'res.currency'
  6. local_name = fields.Char('Local Name')
  7. decimal_separator = fields.Selection([('.', '.'),(',', ',')],'Decimal Separator', default=",", required=True)
  8. decimal_places = fields.Integer(string='Decimal Places', default=0, required=True)
  9. thousands_separator = fields.Selection([('.', '.'),(',', ',')],'thousands Separator', default=".", required=True)
  10. symbol_position = fields.Selection([('before', 'Antes del importe'),('after', 'Después del importe')],'Symbol Position', default="before", required=True)
  11. '''
  12. Deactivate currency
  13. '''
  14. def update_active_currency(self):
  15. return self.env.cr.execute('update res_currency set active=%s where active=%s', ('False','True'))
  16. @api.model
  17. def currency_utility(self):
  18. ## Desactivar todas las moneda
  19. self.update_active_currency()
  20. ## Actualizar Moneda Guarani
  21. currency_pyg = self.env['res.currency'].search([('name', '=', 'PYG'),('active','=',False)])
  22. currency_pyg.write({
  23. 'decimal_separator': ',',
  24. 'decimal_places': 0,
  25. 'thousands_separator' : '.',
  26. 'symbol_position' : 'before',
  27. 'local_name': 'Guaraníes',
  28. 'active': True,
  29. } )
  30. ## Actualizar Moneda Rela brasil
  31. currency_brl = self.env['res.currency'].search([('name', '=', 'BRL'),('active','=',False)])
  32. currency_brl.write({
  33. 'decimal_separator': ',',
  34. 'decimal_places': 2,
  35. 'thousands_separator': '.',
  36. 'symbol_position': 'before',
  37. 'local_name': 'Real',
  38. 'active': True,
  39. })
  40. ## Actualizar Moneda Peso Argentino
  41. currency_ars = self.env['res.currency'].search([('name', '=', 'ARS'),('active','=',False)])
  42. currency_ars.write({
  43. 'decimal_separator': ',',
  44. 'decimal_places': 2,
  45. 'thousands_separator': '.',
  46. 'symbol_position': 'before',
  47. 'local_name': 'Peso Argentino',
  48. 'active': True
  49. })
  50. ## Actualizar Moneda Dolar
  51. currency_usd = self.env['res.currency'].search([('name', '=', 'USD'),('active','=',False)])
  52. currency_usd.write({
  53. 'decimal_separator': '.',
  54. 'decimal_places': 2,
  55. 'thousands_separator': ',',
  56. 'symbol_position': 'before',
  57. 'local_name': 'Dólares',
  58. 'active': True,
  59. })