[FIX] base,l10n_gcc_invoice: apply the 'Total amount in letters' setting
Summary ------- Currently, the 'Total amount of invoice in letters' setting doesn't do anything on GCC invoices. Steps to reproduce ------------------ * install `l10n_sa` * enable the Arabic language * in the settings, enable 'Total amount of invoice in letters' * create and print an invoice You should see that the amount in words in not displayed. Note: Currently, currency labels are not translatable. Since this isn't something that can be changed in stable version, it was decided to not include them in the Arabic amount in words. opw-3501112 opw-3485691 closes odoo/odoo#146364 X-original-commit: 1fb28f229c701ae1261dc502ef345ffda162f994 Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com> Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import fields, models, api
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from num2words import num2words
|
||||
except ImportError:
|
||||
_logger.warning("The num2words python library is not installed, amount-to-text features won't be fully available.")
|
||||
num2words = None
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
@@ -15,6 +25,13 @@ class AccountMove(models.Model):
|
||||
return 'l10n_gcc_invoice.arabic_english_invoice'
|
||||
return super()._get_name_invoice_report()
|
||||
|
||||
def _num2words(self, number, lang):
|
||||
if num2words is None:
|
||||
_logger.warning("The library 'num2words' is missing, cannot render textual amounts.")
|
||||
return ""
|
||||
|
||||
return num2words(number, lang=lang).title()
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
@@ -432,6 +432,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2">
|
||||
<p class="lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
|
||||
Total amount in words: <br/>
|
||||
<span class="text-muted" t-field="o.amount_total_words"/>
|
||||
</p>
|
||||
<p class="text-end lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
|
||||
المبلغ الإجمالي <br/>
|
||||
<span class="text-muted" t-out="o._num2words(o.amount_total, 'ar_001')"/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div t-if="o.currency_id != o.company_id.currency_id"
|
||||
class="row clearfix ms-auto text-nowrap border-top border-bottom p-2">
|
||||
<t t-set="exchange_rate"
|
||||
|
||||
Reference in New Issue
Block a user