Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] report_xlsx: Fix currency format #957

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
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
6 changes: 2 additions & 4 deletions report_xlsx/report/report_abstract_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ def _get_objs_for_report(self, docids, data):
return self.env[self.env.context.get("active_model")].browse(ids)

def _report_xlsx_currency_format(self, currency):
"""Get the format to be used in cells (symbol included).
"""Get currency format to be used in cells.
Used in account_financial_report addon"""
s_before = currency.symbol if currency.position == "before" else ""
s_after = " %s" % currency.symbol if currency.position == "after" else ""
return f"{f'{s_before}'}#,##0.{'0' * currency.decimal_places}{f'{s_after}'}"
return f"#,##0.{'0' * currency.decimal_places}"

def create_xlsx_report(self, docids, data):
objs = self._get_objs_for_report(docids, data)
Expand Down
6 changes: 1 addition & 5 deletions report_xlsx/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,5 @@ def test_id_retrieval(self):
def test_currency_format(self):
usd = self.env.ref("base.USD")
self.assertEqual(
self.xlsx_report._report_xlsx_currency_format(usd), "$#,##0.00"
)
eur = self.env.ref("base.EUR")
self.assertEqual(
self.xlsx_report._report_xlsx_currency_format(eur), "#,##0.00 €"
self.xlsx_report._report_xlsx_currency_format(usd), "#,##0.00"
)
Loading