コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4914 ビュー

Hello,


I am working on a report that contains a table with a 'Total Quantity' cell (A total of all the line quantities). I'd like to show this non-monetary value in 'Words'.



Any help is appreciated, thanks.

アバター
破棄
最善の回答
 In Py
      
  def conv(self, consultation_fee):
        converted_fee=float(consultation_fee)
        convert=self.env.user.company_id.currency_id.amount_to_text(converted_fee)
        return convert

In XML

 <td>
    <span> Amount In Words </span>&#160;:&#160;<span t-esc="doc.conv(doc.consultation_fee)"/>
 </td>

アバター
破棄
最善の回答

Hi,

Try below code

#in .py

from num2words import num2words

#define a function in python to convert

def qty_to_text(self, total):
qty_txt = num2words(total)
return qty_txt

#In .xml

<span t-esc="docs.qty_to_text(docs.total_quantity)"/>

Regards

アバター
破棄
関連投稿 返信 ビュー 活動
1
4月 24
2238
0
10月 21
5124
1
9月 21
6323
0
3月 17
3278
2
4月 23
8580