diff --git a/currency_rate_update/README.rst b/currency_rate_update/README.rst index 011328481..fa1b2b416 100644 --- a/currency_rate_update/README.rst +++ b/currency_rate_update/README.rst @@ -102,6 +102,7 @@ Contributors * Miku Laitinen * Assem Bayahi * Daniel Dico (BOC) +* Dmytro Katyukha Maintainer diff --git a/currency_rate_update/__init__.py b/currency_rate_update/__init__.py index 9186ee3ad..d99ae047e 100644 --- a/currency_rate_update/__init__.py +++ b/currency_rate_update/__init__.py @@ -1 +1,2 @@ from . import model +from .services.currency_getter_interface import CurrencyGetterInterface diff --git a/currency_rate_update/__openerp__.py b/currency_rate_update/__openerp__.py index c90da1c72..b59d44c5f 100644 --- a/currency_rate_update/__openerp__.py +++ b/currency_rate_update/__openerp__.py @@ -19,7 +19,7 @@ "security/rule.xml", "security/ir.model.access.csv", ], + "images": [], "demo": [], - "active": False, 'installable': True } diff --git a/currency_rate_update/model/currency_rate_update.py b/currency_rate_update/model/currency_rate_update.py index d90e881ba..143de88a6 100644 --- a/currency_rate_update/model/currency_rate_update.py +++ b/currency_rate_update/model/currency_rate_update.py @@ -11,7 +11,8 @@ from dateutil.relativedelta import relativedelta from openerp import models, fields, api, _ from openerp import exceptions -from ..services.currency_getter import Currency_getter_factory +from ..services.currency_getter_interface import CurrencyGetterType + _logger = logging.getLogger(__name__) @@ -21,103 +22,8 @@ _intervalTypes = { 'months': lambda interval: relativedelta(months=interval), } -supported_currency_array = [ - "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", - "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", - "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", - "COP", "CRC", "CUP", "CVE", "CYP", "CZK", "DJF", "DKK", "DOP", "DZD", - "EEK", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", - "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", - "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", - "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", - "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", - "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MTL", "MUR", "MVR", - "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", - "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", - "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", - "SLL", "SOS", "SPL", "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", - "TMM", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", - "USD", "UYU", "UZS", "VEB", "VEF", "VND", "VUV", "WST", "XAF", "XAG", - "XAU", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "YER", "ZAR", "ZMK", - "ZWD" -] -YAHOO_supported_currency_array = [ - "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", - "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", - "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", - "CNH", "CNY", "COP", "CRC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", - "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", - "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", - "IDR", "IEP", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", - "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", - "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", - "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", - "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", - "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", - "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", - "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", - "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", - "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XCP", "XDR", "XOF", - "XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL"] - -RO_BNR_supported_currency_array = [ - "AED", "AUD", "BGN", "BRL", "CAD", "CHF", "CNY", "CZK", "DKK", "EGP", - "EUR", "GBP", "HUF", "INR", "JPY", "KRW", "MDL", "MXN", "NOK", "NZD", - "PLN", "RON", "RSD", "RUB", "SEK", "TRY", "UAH", "USD", "XAU", "XDR", - "ZAR"] - -CA_BOC_supported_currency_array = [ - "AED", "ANG", "ARS", "AUD", "BOC", "BRL", "BSD", "CHF", "CLP", "CNY", - "COP", "CZK", "DKK", "EUR", "FJD", "GBP", "GHS", "GTQ", "HKD", "HNL", - "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JMD", "JPY", "KRW", "LKR", - "MAD", "MMK", "MXN", "MYR", "NOK", "NZD", "PAB", "PEN", "PHP", "PKR", - "PLN", "RON", "RSD", "RUB", "SEK", "SGD", "THB", "TND", "TRY", "TTD", - "TWD", "USD", "VEF", "VND", "XAF", "XCD", "XPF", "ZAR"] - -CH_ADMIN_supported_currency_array = [ - "AED", "ALL", "ARS", "AUD", "AZN", "BAM", "BDT", "BGN", "BHD", "BRL", - "CAD", "CHF", "CLP", "CNY", "COP", "CRC", "CZK", "DKK", "DOP", "EGP", - "ETB", "EUR", "GBP", "GTQ", "HKD", "HNL", "HRK", "HUF", "IDR", "ILS", - "INR", "ISK", "JPY", "KES", "KHR", "KRW", "KWD", "KYD", "KZT", "LBP", - "LKR", "LTL", "LVL", "LYD", "MAD", "MUR", "MXN", "MYR", "NGN", "NOK", - "NZD", "OMR", "PAB", "PEN", "PHP", "PKR", "PLN", "QAR", "RON", "RSD", - "RUB", "SAR", "SEK", "SGD", "THB", "TND", "TRY", "TWD", "TZS", "UAH", - "USD", "UYU", "VEF", "VND", "ZAR"] - -ECB_supported_currency_array = [ - "AUD", "BGN", "BRL", "CAD", "CHF", "CNY", "CZK", "DKK", "EUR", "GBP", - "HKD", "HRK", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "LTL", "MXN", - "MYR", "NOK", "NZD", "PHP", "PLN", "RON", "RUB", "SEK", "SGD", "THB", - "TRY", "USD", "ZAR"] - -MX_BdM_supported_currency_array = [ - "ARS", "AUD", "BBD", "BMD", "BOB", "BRL", "BSD", "BZD", "CAD", "CHF", - "CLP", "CNH", "CNY", "COP", "CRC", "CUP", "CZK", "DKK", "DOP", "DZD", - "EGP", "ESD", "EUR", "FJD", "GBP", "GTQ", "GYD", "HKD", "HNL", "HUF", - "IDR", "ILS", "INR", "IQD", "JMD", "JPY", "KES", "KRW", "KWD", "MAD", - "MYR", "NGN", "NIC", "NOK", "NZD", "PAB", "PEN", "PHP", "PLN", "PYG", - "RON", "RUB", "SAR", "SEK", "SGD", "SVC", "THB", "TRY", "TTD", "TWD", - "UAH", "USD", "USD", "UYP", "VEF", "VND", "ZAR"] - -PL_NBP_supported_currency_array = [ - "AUD", "BGN", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", - "GBP", "HKD", "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JPY", "KRW", - "LTL", "MXN", "MYR", "NOK", "NZD", "PHP", "PLN", "RON", "RUB", "SEK", - "SGD", "THB", "TRY", "UAH", "USD", "XDR", "ZAR"] - -supported_currecies = { - 'YAHOO_getter': YAHOO_supported_currency_array, - 'ECB_getter': ECB_supported_currency_array, - 'RO_BNR_getter': RO_BNR_supported_currency_array, - 'CA_BOC_getter': CA_BOC_supported_currency_array, - 'CH_ADMIN_getter': CH_ADMIN_supported_currency_array, - 'MX_BdM_getter': MX_BdM_supported_currency_array, - 'PL_NBP_getter': PL_NBP_supported_currency_array, - } - - -class Currency_rate_update_service(models.Model): +class CurrencyRateUpdateService(models.Model): """Class keep services and currencies that have to be updated""" _name = "currency.rate.update.service" @@ -147,29 +53,19 @@ class Currency_rate_update_service(models.Model): currency_list = '' if self.service: currencies = [] - currency_list = supported_currency_array - currency_list = supported_currecies[self.service] + getter = CurrencyGetterType.get(self.service) + currency_list = getter.supported_currency_array currencies = self.env['res.currency'].search( [('name', 'in', currency_list)]) self.currency_list = [(6, 0, [curr.id for curr in currencies])] + def _selection_service(self, *a, **k): + res = [(x.code, x.name) for x in CurrencyGetterType.getters.values()] + return res + # List of webservicies the value sould be a class name service = fields.Selection( - [('CH_ADMIN_getter', 'Admin.ch'), - ('ECB_getter', 'European Central Bank'), - ('YAHOO_getter', 'Yahoo Finance'), - # Added for polish rates - ('PL_NBP_getter', 'National Bank of Poland'), - # Added for mexican rates - ('MX_BdM_getter', 'Bank of Mexico'), - # Bank of Canada is using RSS-CB - # http://www.cbwiki.net/wiki/index.php/Specification_1.1 - # This RSS format is used by other national banks - # (Thailand, Malaysia, Mexico...) - ('CA_BOC_getter', 'Bank of Canada - noon rates'), - # Added for romanian rates - ('RO_BNR_getter', 'National Bank of Romania') - ], + _selection_service, string="Webservice to use", required=True) # List of currencies available on webservice @@ -217,7 +113,6 @@ class Currency_rate_update_service(models.Model): _logger.info( 'Starting to refresh currencies with service %s (company: %s)', self.service, self.company_id.name) - factory = Currency_getter_factory() rate_obj = self.env['res.currency.rate'] company = self.company_id # The multi company currency can be set or no so we handle @@ -234,9 +129,8 @@ class Currency_rate_update_service(models.Model): try: # We initalize the class that will handle the request # and return a dict of rate - getter = factory.register(self.service) - curr_to_fetch = map(lambda x: x.name, - self.currency_to_update) + getter = CurrencyGetterType.get(self.service) + curr_to_fetch = [x.name for x in self.currency_to_update] res, log_info = getter.get_updated_currency( curr_to_fetch, main_currency.name, @@ -288,6 +182,7 @@ class Currency_rate_update_service(models.Model): _intervalTypes[str(self.interval_type)] (self.interval_number)).date() self.next_run = next_run + return True @api.multi def run_currency_update(self): diff --git a/currency_rate_update/services/__init__.py b/currency_rate_update/services/__init__.py index e69de29bb..e08882d2e 100644 --- a/currency_rate_update/services/__init__.py +++ b/currency_rate_update/services/__init__.py @@ -0,0 +1,8 @@ +# Note, that CA_BOC getter seems not to be working +from . import update_service_CA_BOC +from . import update_service_CH_ADMIN +from . import update_service_ECB +from . import update_service_YAHOO +from . import update_service_PL_NBP +from . import update_service_MX_BdM +from . import update_service_RO_BNR diff --git a/currency_rate_update/services/currency_getter.py b/currency_rate_update/services/currency_getter.py deleted file mode 100644 index 074c06a18..000000000 --- a/currency_rate_update/services/currency_getter.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2008-2016 Camptocamp -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -class AbstractClassError(Exception): - def __str__(self): - return 'Abstract Class' - - def __repr__(self): - return 'Abstract Class' - - -class AbstractMethodError(Exception): - def __str__(self): - return 'Abstract Method' - - def __repr__(self): - return 'Abstract Method' - - -class UnknowClassError(Exception): - def __str__(self): - return 'Unknown Class' - - def __repr__(self): - return 'Unknown Class' - - -class UnsuportedCurrencyError(Exception): - def __init__(self, value): - self.curr = value - - def __str__(self): - return 'Unsupported currency %s' % self.curr - - def __repr__(self): - return 'Unsupported currency %s' % self.curr - - -class Currency_getter_factory(): - """Factory pattern class that will return - a currency getter class base on the name passed - to the register method - - """ - def register(self, class_name): - allowed = [ - 'CH_ADMIN_getter', - 'PL_NBP_getter', - 'ECB_getter', - 'GOOGLE_getter', - 'YAHOO_getter', - 'MX_BdM_getter', - 'CA_BOC_getter', - 'RO_BNR_getter', - ] - if class_name in allowed: - exec "from .update_service_%s import %s" % \ - (class_name.replace('_getter', ''), class_name) - class_def = eval(class_name) - return class_def() - else: - raise UnknowClassError diff --git a/currency_rate_update/services/currency_getter_interface.py b/currency_rate_update/services/currency_getter_interface.py index b6f4125d0..f1a4b1ee0 100644 --- a/currency_rate_update/services/currency_getter_interface.py +++ b/currency_rate_update/services/currency_getter_interface.py @@ -46,8 +46,55 @@ class UnsuportedCurrencyError(Exception): return 'Unsupported currency %s' % self.curr -class Currency_getter_interface(object): - "Abstract class of currency getter" +class CurrencyGetterType(type): + """ Meta class for currency getters. + Automaticaly registers new curency getter on class definition + """ + getters = {} + + def __new__(mcs, name, bases, attrs): + cls = super(CurrencyGetterType, mcs).__new__(mcs, name, bases, attrs) + if getattr(cls, 'code', None): + mcs.getters[cls.code] = cls + return cls + + @classmethod + def get(mcs, code, *args, **kwargs): + """ Get getter by code + """ + return mcs.getters[code](*args, **kwargs) + + +class CurrencyGetterInterface(object): + """ Abstract class of currency getter + + To create new getter, just subclass this class + and define class variables 'code' and 'name' + and implement *get_updated_currency* method + + For example:: + + from openerp.addons.currency_rate_update \ + import CurrencyGetterInterface + + class MySuperCurrencyGetter(CurrencyGetterInterface): + code = "MSCG" + name = "My Currency Rates" + supported_currency_array = ['USD', 'EUR'] + + def get_updated_currency(self, currency_array, main_currency, + max_delta_days): + # your code that fills self.updated_currency + + # and return result + return self.updated_currency, self.log_info + + """ + __metaclass__ = CurrencyGetterType + + # attributes required for currency getters + code = None # code for service selection + name = None # displayed name log_info = " " diff --git a/currency_rate_update/services/update_service_CA_BOC.py b/currency_rate_update/services/update_service_CA_BOC.py index b17ea3144..d50fada88 100644 --- a/currency_rate_update/services/update_service_CA_BOC.py +++ b/currency_rate_update/services/update_service_CA_BOC.py @@ -3,7 +3,7 @@ # © 2014 Daniel Dico # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface from openerp import _ from openerp.exceptions import except_orm @@ -12,11 +12,26 @@ import logging _logger = logging.getLogger(__name__) -class CA_BOC_getter(Currency_getter_interface): +class CA_BOCGetter(CurrencyGetterInterface): """Implementation of Curreny_getter_factory interface for Bank of Canada RSS service """ + # Bank of Canada is using RSS-CB + # http://www.cbwiki.net/wiki/index.php/Specification_1.1 + # This RSS format is used by other national banks + # (Thailand, Malaysia, Mexico...) + + code = 'CA_BOC' + name = 'Bank of Canada - noon rates' + + supported_currency_array = [ + "AED", "ANG", "ARS", "AUD", "BOC", "BRL", "BSD", "CHF", "CLP", "CNY", + "COP", "CZK", "DKK", "EUR", "FJD", "GBP", "GHS", "GTQ", "HKD", "HNL", + "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JMD", "JPY", "KRW", "LKR", + "MAD", "MMK", "MXN", "MYR", "NOK", "NZD", "PAB", "PEN", "PHP", "PKR", + "PLN", "RON", "RSD", "RUB", "SEK", "SGD", "THB", "TND", "TRY", "TTD", + "TWD", "USD", "VEF", "VND", "XAF", "XCD", "XPF", "ZAR"] def get_updated_currency(self, currency_array, main_currency, max_delta_days): diff --git a/currency_rate_update/services/update_service_CH_ADMIN.py b/currency_rate_update/services/update_service_CH_ADMIN.py index a7b26d44f..e2e32aea2 100644 --- a/currency_rate_update/services/update_service_CH_ADMIN.py +++ b/currency_rate_update/services/update_service_CH_ADMIN.py @@ -2,7 +2,7 @@ # © 2008 Camptocamp # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface import logging from datetime import datetime from openerp.tools import DEFAULT_SERVER_DATE_FORMAT @@ -10,11 +10,24 @@ from openerp.tools import DEFAULT_SERVER_DATE_FORMAT _logger = logging.getLogger(__name__) -class CH_ADMIN_getter(Currency_getter_interface): +class CH_ADMINGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for Admin.ch service. """ + code = 'CH_ADMIN' + name = 'Admin.ch' + + supported_currency_array = [ + "AED", "ALL", "ARS", "AUD", "AZN", "BAM", "BDT", "BGN", "BHD", "BRL", + "CAD", "CHF", "CLP", "CNY", "COP", "CRC", "CZK", "DKK", "DOP", "EGP", + "ETB", "EUR", "GBP", "GTQ", "HKD", "HNL", "HRK", "HUF", "IDR", "ILS", + "INR", "ISK", "JPY", "KES", "KHR", "KRW", "KWD", "KYD", "KZT", "LBP", + "LKR", "LTL", "LVL", "LYD", "MAD", "MUR", "MXN", "MYR", "NGN", "NOK", + "NZD", "OMR", "PAB", "PEN", "PHP", "PKR", "PLN", "QAR", "RON", "RSD", + "RUB", "SAR", "SEK", "SGD", "THB", "TND", "TRY", "TWD", "TZS", "UAH", + "USD", "UYU", "VEF", "VND", "ZAR"] + def rate_retrieve(self, dom, ns, curr): """Parse a dom node to retrieve currencies data""" res = {} diff --git a/currency_rate_update/services/update_service_ECB.py b/currency_rate_update/services/update_service_ECB.py index fc47ca7c9..16156e98a 100644 --- a/currency_rate_update/services/update_service_ECB.py +++ b/currency_rate_update/services/update_service_ECB.py @@ -3,7 +3,7 @@ # © 2009 Grzegorz Grzelak # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface from datetime import datetime from openerp.tools import DEFAULT_SERVER_DATE_FORMAT @@ -12,10 +12,17 @@ import logging _logger = logging.getLogger(__name__) -class ECB_getter(Currency_getter_interface): +class ECBGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for ECB service """ + code = 'ECB' + name = 'European Central Bank' + supported_currency_array = [ + "AUD", "BGN", "BRL", "CAD", "CHF", "CNY", "CZK", "DKK", "EUR", "GBP", + "HKD", "HRK", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "LTL", "MXN", + "MYR", "NOK", "NZD", "PHP", "PLN", "RON", "RUB", "SEK", "SGD", "THB", + "TRY", "USD", "ZAR"] def rate_retrieve(self, dom, ns, curr): """Parse a dom node to retrieve- diff --git a/currency_rate_update/services/update_service_MX_BdM.py b/currency_rate_update/services/update_service_MX_BdM.py index 5290f4193..4d0bc30f0 100644 --- a/currency_rate_update/services/update_service_MX_BdM.py +++ b/currency_rate_update/services/update_service_MX_BdM.py @@ -3,17 +3,27 @@ # © 2013-2014 Agustin Cruz openpyme.mx # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface import logging _logger = logging.getLogger(__name__) -class MX_BdM_getter(Currency_getter_interface): +class MX_BdMGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for Banco de México service """ + code = 'MX_BdM' + name = 'Bank of Mexico' + supported_currency_array = [ + "ARS", "AUD", "BBD", "BMD", "BOB", "BRL", "BSD", "BZD", "CAD", "CHF", + "CLP", "CNH", "CNY", "COP", "CRC", "CUP", "CZK", "DKK", "DOP", "DZD", + "EGP", "ESD", "EUR", "FJD", "GBP", "GTQ", "GYD", "HKD", "HNL", "HUF", + "IDR", "ILS", "INR", "IQD", "JMD", "JPY", "KES", "KRW", "KWD", "MAD", + "MYR", "NGN", "NIC", "NOK", "NZD", "PAB", "PEN", "PHP", "PLN", "PYG", + "RON", "RUB", "SAR", "SEK", "SGD", "SVC", "THB", "TRY", "TTD", "TWD", + "UAH", "USD", "USD", "UYP", "VEF", "VND", "ZAR"] def rate_retrieve(self): """ Get currency exchange from Banxico.xml and proccess it diff --git a/currency_rate_update/services/update_service_PL_NBP.py b/currency_rate_update/services/update_service_PL_NBP.py index c334aaa81..e25ad925e 100644 --- a/currency_rate_update/services/update_service_PL_NBP.py +++ b/currency_rate_update/services/update_service_PL_NBP.py @@ -3,7 +3,7 @@ # © 2009 Grzegorz Grzelak # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface from datetime import datetime from openerp.tools import DEFAULT_SERVER_DATE_FORMAT @@ -12,11 +12,19 @@ import logging _logger = logging.getLogger(__name__) -class PL_NBP_getter(Currency_getter_interface): +class PL_NBPGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for PL NBP service """ + code = 'PL_NBP' + name = 'National Bank of Poland' + + supported_currency_array = [ + "AUD", "BGN", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", + "GBP", "HKD", "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JPY", "KRW", + "LTL", "MXN", "MYR", "NOK", "NZD", "PHP", "PLN", "RON", "RUB", "SEK", + "SGD", "THB", "TRY", "UAH", "USD", "XDR", "ZAR"] def rate_retrieve(self, dom, ns, curr): """ Parse a dom node to retrieve diff --git a/currency_rate_update/services/update_service_RO_BNR.py b/currency_rate_update/services/update_service_RO_BNR.py index ecb9b740c..650bcb85f 100644 --- a/currency_rate_update/services/update_service_RO_BNR.py +++ b/currency_rate_update/services/update_service_RO_BNR.py @@ -3,7 +3,7 @@ # © 2014 Dorin Hongu # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface from datetime import datetime, timedelta @@ -11,9 +11,17 @@ import logging _logger = logging.getLogger(__name__) -class RO_BNR_getter(Currency_getter_interface): +class RO_BNRGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for BNR service""" + code = 'RO_BNR' + name = 'National Bank of Romania' + supported_currency_array = [ + "AED", "AUD", "BGN", "BRL", "CAD", "CHF", "CNY", "CZK", "DKK", "EGP", + "EUR", "GBP", "HUF", "INR", "JPY", "KRW", "MDL", "MXN", "NOK", "NZD", + "PLN", "RON", "RSD", "RUB", "SEK", "TRY", "UAH", "USD", "XAU", "XDR", + "ZAR"] + def rate_retrieve(self, dom, ns, curr): """ Parse a dom node to retrieve- currencies data""" diff --git a/currency_rate_update/services/update_service_YAHOO.py b/currency_rate_update/services/update_service_YAHOO.py index 1b330d57d..1ecde3ebe 100644 --- a/currency_rate_update/services/update_service_YAHOO.py +++ b/currency_rate_update/services/update_service_YAHOO.py @@ -2,13 +2,34 @@ # © 2009 Camptocamp # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from .currency_getter_interface import Currency_getter_interface +from .currency_getter_interface import CurrencyGetterInterface -class YAHOO_getter(Currency_getter_interface): +class YAHOOGetter(CurrencyGetterInterface): """Implementation of Currency_getter_factory interface for Yahoo finance service """ + code = 'YAHOO' + name = 'Yahoo Finance' + + supported_currency_array = [ + "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", + "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", + "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", + "CNH", "CNY", "COP", "CRC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", + "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", + "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", + "IDR", "IEP", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", + "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", + "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", + "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", + "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", + "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", + "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", + "SRD", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", + "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", + "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XCP", "XDR", "XOF", + "XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL"] def get_updated_currency(self, currency_array, main_currency, max_delta_days): diff --git a/currency_rate_update/view/currency_rate_update.xml b/currency_rate_update/view/currency_rate_update.xml index c977e91b0..bd0cf62ab 100644 --- a/currency_rate_update/view/currency_rate_update.xml +++ b/currency_rate_update/view/currency_rate_update.xml @@ -29,6 +29,8 @@ invisible="not context.get('currency_rate_update_main_view')" required="context.get('currency_rate_update_main_view')"/> +