Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .docker_files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
git+https://github.com/numigi/aeroolib@master
git+https://github.com/aeroo/currency2text@master
babel==2.5.3
Genshi==0.7.5
freezegun==0.3.10
Expand Down
2 changes: 1 addition & 1 deletion report_aeroo/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'website': 'https://bit.ly/numigi-com',
'depends': ['mail'],
'external_dependencies': {
'python': ['aeroolib', 'babel', 'genshi'],
'python': ['aeroolib', 'babel', 'currency2text', 'genshi'],
},
'data': [
"security/security.xml",
Expand Down
18 changes: 18 additions & 0 deletions report_aeroo/extra_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import time
from babel.core import localedata
from currency2text import supported_language
from datetime import datetime, date, timedelta
from html2text import html2text
from io import BytesIO
Expand Down Expand Up @@ -72,6 +73,23 @@ def decorator(func):
return decorator


@aeroo_util("currency_to_text")
def currency_to_text(report, sum, currency = None, language = None):
lang = report._context.get("lang") or "en_US"
s_lang = supported_language.get(language or lang)
context = report._context
currency = currency or context.get("currency")
if currency is None:
raise ValidationError(
_(
"The function `currency_to_text` can not be evaluated without a currency. "
"You must either define a currency in the field `Currency Evaluation` of the "
"Aeroo report or call the function with a currency explicitely."
)
)
return str(s_lang.currency_to_text(sum, currency), "UTF-8")


@aeroo_util("format_hours")
def format_hours(report, value):
hours = str(int(abs(value) // 1))
Expand Down