Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
4033 มุมมอง

I converted the actual amount to word but the cents are not converted here's my .py code

    def _get_amount_in_words(self, amount_total):

        # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes

        amount_in_words = amount_to_text_en.amount_to_text(math.floor(amount_total), lang='en', currency='')

        amount_in_words = amount_in_words.replace(' and Zero Cent', '') # Ugh

        decimals = amount_total % 1

        if not float_is_zero(decimals, precision_digits=2):

            amount_in_words += _(' and %s ') % str(int(round(float_round(decimals*100, precision_rounding=1))))

        return amount_in_words


    @api.onchange('amount_total')

    def _onchange_amount_total(self):

        if hasattr(super(InvoiceTemplate, self), '_onchange_amount_total'):

            super(InvoiceTemplate, self)._onchange_amount_total()

        self.amount_in_words = self._get_amount_in_words(self.amount_total)

I am getting as out put:
"five hundred and 78 Cents" 
อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

the issuing i'm facing is the cents are not converted, other that is working fine

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hope this will helps you:

http://learnopenerp.blogspot.com/2017/11/how-to-convert-number-into-words.html


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 23
2025
0
พ.ย. 16
4589
1
มี.ค. 20
4844
what means _ in Odoo 10? แก้ไขแล้ว
1
มี.ค. 19
4552
0
พ.ย. 17
3886