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

bonjour,

merci de m aider pour convertir les champs en chiffre vers lettre 

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

hi

Thanks for your help, after model update , it shows this error

"depends on the num2words module. But the latter is not available on your system. "



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

Hi aadnan,

You can use in odoo17

from odoo import models, fields, api

from num2words import num2words


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    amount_in_words = fields.Char(string="Amount in Words", compute='_compute_amount_in_words')


    @api.depends('amount_total')

    def _compute_amount_in_words(self):

        for order in self:

            order.amount_in_words = num2words(order.amount_total, lang='fr')


Using num2words using change amount to Text 

Based on Odoo requirement.txt available library 


Thanks

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

Dear Aadnan,

Using  num2words  library

import num2words


def convert_to_letters(number):

    return num2words.number_to_words(number, lang='fr')


# Example usage

numerical_field = 12345

letter_representation = convert_to_letters(numerical_field)

print(letter_representation)  # Output: Douze mille trois cent quarante-cinq


 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 19
3574
4
thg 8 19
4817
4
thg 4 25
3162
2
thg 6 24
2166
2
thg 5 23
3731