İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
2466 Görünümler

Hello, 

How can I add the invoice amount as text. I have Odoo V14 and studio.

Avatar
Vazgeç
En İyi Yanıt

Hi,

If you need to do it using studio you can utilize the amount_to_text function from the res.currency model. You can define a computed field or use the function inside automated action or as per your need.

Suppose if you have an object of res.currency model, let say, currency_id and amount_total as amount then:

currency_id.amount_to_text(amount_total) will give you the amount in words of passed amount.


Thanks

Avatar
Vazgeç
En İyi Yanıt

Hi,

You can just use the num2words, here is the sample code this may help you,

python

from num2words import num2words

class AccountMove(models.Model):
_inherit = 'account.move'

invoice_amount = fields.Text(string="Invoice Amount", help="To amount as text")

@api.onchange('invoice_line_ids')
def get_amount_in_text(self):
self.invoice_amount = num2words(self.amount_total)

XML:

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <record id="account_move_inherit_view" model="ir.ui.view">
        <field name="name">account.move.inherit</field>
        <field name="model">account.move</field>
        <field name="inherit_id" ref="account.view_move_form"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook" position="inside">
                <field name="invoice_amount"/>
            </xpath>
        </field>
    </record>
</odoo>


Regards

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
4
Eyl 24
2317
2
Eyl 24
1522
0
Ağu 22
4891
0
Ara 20
12
0
Ara 20
2987