-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcurrency.py
36 lines (27 loc) · 946 Bytes
/
currency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
from trytond.pool import PoolMeta
__all__ = ['Currency']
__metaclass__ = PoolMeta
class Currency:
"Currency"
__name__ = 'currency.currency'
@classmethod
def __setup__(cls):
"""
Setup the class before adding to pool
"""
super(Currency, cls).__setup__()
cls._error_messages.update({
'currency_not_found': 'Currency with code %s does not exist.',
})
@classmethod
def search_using_magento_code(cls, currency_code):
"""
Search for currency with given magento currency code.
:param currency_code: currency code given by magento
:return: Active record of currency if found else raises error
"""
currencies = cls.search([('code', '=', currency_code)])
if not currencies:
return cls.raise_user_error('currency_not_found', (currency_code, ))
return currencies[0]