+
ITA - Localizzazione valute per amount_to_text
+
+
+

+
Italiano
+
Il core di Odoo fornisce amount_to_text, il quale converte importi
+numerici in testo ottenendo la lingua dal contesto fornito o dalle
+impostazioni utente/partner, con alcune limitazioni.
+
Esempio: 45,75 €
+
+- Lingua utente “Inglese” → Forty-Five Euros and Seventy-Five Cents
+- Lingua utente “Italiano” → Quarantacinque Euros e Settantacinque
+Cents
+
+
L’unità/sottounità di valuta non viene tradotta e non viene gestita la
+forma singolare. Inoltre tutte le parole possiedono l’iniziale
+maiuscola, forma non corretta nella lingua italiana.
+
Questo modulo fornisce una base per tradurre le unità/sottounità di
+valuta, adattando le parole alle regole della lingua italiana.
+
Vengono inoltre gestite le eccezioni per la forma singolare delle valute
+EUR, USD, GBP e CNY.
+
Esempio: 1,01 €
+
+- La parte intera diventa “un euro”, non “uno euro”
+- La parte decimale diventa “un centesimo”, non “uno centesimi”
+
+
English
+
Odoo core provides amount_to_text, which converts numerical amounts
+to text getting language from given context or user/partner setting,
+with some limitations.
+
Example: 45,75 €
+
+- User Language ‘English’ -> Forty-Five Euros and Seventy-Five Cents
+- User Language ‘Italian’ -> Quaranta Euros e Settantacinque Cents
+
+
Currency unit/subunit is not translated and singular form is not
+handled. Moreover all words are capitalized, which is incorrect in
+italian language.
+
This module provides a base for translating currency unit/subunit
+adapting words to italian language rules.
+
Singular form expections for EUR, USD, GBP and CNY currencies are
+handled as well.
+
Example: 1,01 €
+
+- Integer part becomes “un euro”, not “uno euro”
+- Decimal part becomes “un centesimo”, not “uno centesimi”
+
+
Table of contents
+
+
+
+
Italiano
+
Versione libreria num2words >= 0.5.12
+
English
+
num2words library version >= 0.5.12
+
+
+
+
Italiano
+
Chiamare la funzione amount_to_text nel modello valuta
+(res.currency).
+
Per esempio, se è necessario convertire un importo in testo aggiungere
+questo codice ai report:
+
+<t t-foreach="docs" t-as="o">
+ <t t-set="currency" t-value="o.currency_id"/>
+ <!-- Language obtained from context -->
+ <t t-out="currency.with_context(lang='it_IT').amount_to_text(45.75)"/>
+
+ <!-- Language obtained from user/partner settings.
+ If not it_IT, Odoo core amount_to_text will be used. -->
+ <t t-out="currency.amount_to_text(45.75)"/>
+</t>
+
+
English
+
Call function amount_to_text in currency model (res.currency).
+
For example, add this code if you need to convert amount to text in your
+reports:
+
+<t t-foreach="docs" t-as="o">
+ <t t-set="currency" t-value="o.currency_id"/>
+ <!-- Language obtained from context -->
+ <t t-out="currency.with_context(lang='it_IT').amount_to_text(45.75)"/>
+
+ <!-- Language obtained from user/partner settings.
+ If not it_IT, Odoo core amount_to_text will be used. -->
+ <t t-out="currency.amount_to_text(45.75)"/>
+</t>
+
+
+
+
+
Bugs are tracked on GitHub Issues.
+In case of trouble, please check there if your issue has already been reported.
+If you spotted it first, help us to smash it by providing a detailed and welcomed
+feedback.
+
Do not contact contributors directly about support or help with technical issues.
+
+
+
+
+
+
+- Sergio Zanchetta - Associazione PNLug APS
+- Ecosoft Co. Ltd
+
+
+
+
+
+
This module is maintained by the OCA.
+
+
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
+mission is to support the collaborative development of Odoo features and
+promote its widespread use.
+
This module is part of the OCA/l10n-italy project on GitHub.
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
+
+
+
+
+
diff --git a/l10n_it_amount_to_text/tests/__init__.py b/l10n_it_amount_to_text/tests/__init__.py
new file mode 100644
index 000000000000..22e0c06be7e6
--- /dev/null
+++ b/l10n_it_amount_to_text/tests/__init__.py
@@ -0,0 +1,3 @@
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
+
+from . import test_amount_to_text
diff --git a/l10n_it_amount_to_text/tests/test_amount_to_text.py b/l10n_it_amount_to_text/tests/test_amount_to_text.py
new file mode 100644
index 000000000000..06a6bd56eb3c
--- /dev/null
+++ b/l10n_it_amount_to_text/tests/test_amount_to_text.py
@@ -0,0 +1,65 @@
+# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th)
+# Copyright 2022 Sergio Zanchetta (Associazione PNLUG - Gruppo Odoo)
+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
+
+from num2words import num2words
+
+from odoo.tests.common import TransactionCase
+
+
+class TestAmountToText(TransactionCase):
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.env(context=dict(cls.env.context, tracking_disable=True))
+ cls.env["res.lang"]._activate_lang("it_IT")
+
+ def test_01_currency_it_amount_to_text(self):
+ """check that amount_to_text correctly converts text
+ to italian language"""
+ currency = self.env.ref("base.EUR")
+ amount = 1050.75
+ amount_text_en = currency.amount_to_text(amount)
+ self.assertEqual(
+ amount_text_en, "One Thousand And Fifty Euros and Seventy-Five Cents"
+ )
+ amount_text_it = currency.with_context(lang="it_IT").amount_to_text(amount)
+ num2words(amount, to="currency", lang="it")
+ self.assertEqual(
+ amount_text_it, "millecinquanta euro e settantacinque centesimi"
+ )
+
+ def test_02_currency_unit_it_amount_to_text(self):
+ """check that amount_to_text correctly converts currency
+ unit/subunit to italian language singular form"""
+ currency = self.env.ref("base.EUR")
+ amount = 1.01
+ amount_text_it_unit = currency.with_context(lang="it_IT").amount_to_text(amount)
+ self.assertEqual(amount_text_it_unit, "un euro e un centesimo")
+
+ def test_03_currency_usd_amount_to_text(self):
+ """check that amount_to_text works as expected"""
+ currency = self.env.ref("base.USD")
+ amount = 1050.75
+ amount_text_usd = currency.amount_to_text(amount)
+ self.assertEqual(
+ amount_text_usd, "One Thousand And Fifty Dollars and Seventy-Five Cents"
+ )
+
+ def test_04_currency_zero_fractional_value_it_amount_to_text(self):
+ """check that amount_to_text correctly converts currency
+ with zero fractional value"""
+ currency = self.env.ref("base.EUR")
+ amount = 3.00
+ amount_text_it_zero_fractional = currency.with_context(
+ lang="it_IT"
+ ).amount_to_text(amount)
+ self.assertEqual(amount_text_it_zero_fractional, "tre euro e zero centesimi")
+
+ def test_05_currency_aed_amount_to_text(self):
+ """check that amount_to_text works in italian language
+ using a currency different from EUR/USD/GBP/CNY"""
+ currency = self.env.ref("base.AED")
+ amount = 1050.75
+ amount_text_aed = currency.with_context(lang="it_IT").amount_to_text(amount)
+ self.assertEqual(amount_text_aed, "millecinquanta dirham e settantacinque fils")
diff --git a/requirements.txt b/requirements.txt
index d1d1ac5a796d..178abf294635 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,5 @@
# generated from manifests external_dependencies
codicefiscale
+num2words>=0.5.12
openupgradelib
unidecode