Skip to content

Commit

Permalink
[MIG] l10n_it_amount_to_text: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h committed Jan 29, 2025
1 parent e5e6226 commit 72c2029
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
8 changes: 4 additions & 4 deletions l10n_it_amount_to_text/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ 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-esc="currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)"/>
<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-esc="currency.amount_to_text(45.75)"/>
<t t-out="currency.amount_to_text(45.75)"/>
</t>

**English**
Expand All @@ -132,11 +132,11 @@ reports:
<t t-foreach="docs" t-as="o">
<t t-set="currency" t-value="o.currency_id"/>
# Language obtained from context
<t t-esc="currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)"/>
<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-esc="currency.amount_to_text(45.75)"/>
<t t-out="currency.amount_to_text(45.75)"/>
</t>

Bug Tracker
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_amount_to_text/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "ITA - Localizzazione valute per amount_to_text",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Localization/Italy",
"summary": "Localizza le valute in italiano per amount_to_text",
"author": "Sergio Zanchetta - Associazione PNLug APS,"
Expand Down
8 changes: 4 additions & 4 deletions l10n_it_amount_to_text/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ 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-esc="currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)"/>
<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-esc="currency.amount_to_text(45.75)"/>
<t t-out="currency.amount_to_text(45.75)"/>
</t>

**English**
Expand All @@ -26,9 +26,9 @@ reports:
<t t-foreach="docs" t-as="o">
<t t-set="currency" t-value="o.currency_id"/>
# Language obtained from context
<t t-esc="currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)"/>
<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-esc="currency.amount_to_text(45.75)"/>
<t t-out="currency.amount_to_text(45.75)"/>
</t>
8 changes: 4 additions & 4 deletions l10n_it_amount_to_text/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
&lt;t t-foreach=&quot;docs&quot; t-as=&quot;o&quot;&gt;
&lt;t t-set=&quot;currency&quot; t-value=&quot;o.currency_id&quot;/&gt;
# Language obtained from context
&lt;t t-esc=&quot;currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)&quot;/&gt;
&lt;t t-out=&quot;currency.with_context(lang='it_IT').amount_to_text(45.75)&quot;/&gt;

# Language obtained from user/partner settings.
# If not it_IT, Odoo core amount_to_text will be used.
&lt;t t-esc=&quot;currency.amount_to_text(45.75)&quot;/&gt;
&lt;t t-out=&quot;currency.amount_to_text(45.75)&quot;/&gt;
&lt;/t&gt;
</pre>
<p><strong>English</strong></p>
Expand All @@ -460,11 +460,11 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
&lt;t t-foreach=&quot;docs&quot; t-as=&quot;o&quot;&gt;
&lt;t t-set=&quot;currency&quot; t-value=&quot;o.currency_id&quot;/&gt;
# Language obtained from context
&lt;t t-esc=&quot;currency.with_context({'lang': 'it_IT'}).amount_to_text(45.75)&quot;/&gt;
&lt;t t-out=&quot;currency.with_context(lang='it_IT').amount_to_text(45.75)&quot;/&gt;

# Language obtained from user/partner settings.
# If not it_IT, Odoo core amount_to_text will be used.
&lt;t t-esc=&quot;currency.amount_to_text(45.75)&quot;/&gt;
&lt;t t-out=&quot;currency.amount_to_text(45.75)&quot;/&gt;
&lt;/t&gt;
</pre>
</div>
Expand Down
23 changes: 10 additions & 13 deletions l10n_it_amount_to_text/tests/test_amount_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

from num2words import num2words

from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestAmountToText(SavepointCase):
def setUp(self):
super(TestAmountToText, self).setUp()
self.env["res.lang"]._activate_lang("it_IT")
class TestAmountToText(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
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
Expand All @@ -21,7 +22,7 @@ def test_01_currency_it_amount_to_text(self):
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)
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"
Expand All @@ -32,9 +33,7 @@ def test_02_currency_unit_it_amount_to_text(self):
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
)
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):
Expand All @@ -52,7 +51,7 @@ def test_04_currency_zero_fractional_value_it_amount_to_text(self):
currency = self.env.ref("base.EUR")
amount = 3.00
amount_text_it_zero_fractional = currency.with_context(
{"lang": "it_IT"}
lang="it_IT"
).amount_to_text(amount)
self.assertEqual(amount_text_it_zero_fractional, "tre euro e zero centesimi")

Expand All @@ -61,7 +60,5 @@ def test_05_currency_aed_amount_to_text(self):
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
)
amount_text_aed = currency.with_context(lang="it_IT").amount_to_text(amount)
self.assertEqual(amount_text_aed, "millecinquanta dirham e settantacinque fils")
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ asn1crypto
codicefiscale
elementpath
mock
num2words
num2words>=0.5.12
openupgradelib
unidecode
xmlschema

0 comments on commit 72c2029

Please sign in to comment.