Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4924 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
 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>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
2243
0
thg 10 21
5131
1
thg 9 21
6330
0
thg 3 17
3285
2
thg 4 23
8585