Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

detailed procedure to do the number to text conversion [Closed]

By
selva
on 4/9/13, 9:39 AM 3,955 views

The Question has been closed

by
Sudhir Arya (SA)
on 04/18/2013 05:17:34

hey all!!! i wanted to display my amount figure in words....whether PO,SO etc wherever it is and i also want a field which will do that>....help me....help me openerp community...plz help me...it would be helpful...

3

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/9/13, 9:49 AM

To convert amount to text, you can use the amount_to_text method defined in openerp/tools/amount_to_text_en.py

Create a field which will store text value of amount. You can either create char or text field.

'text_amount': fields.char("Text Amount", size=100)

or

'text_amount': fields.text("Text Amount")

Now write a on_change method which will be called when you change the value of amount field. First add on_change in your xml where your amount field is.

Like this:

<field name="your_amount_field" on_change="onchange_amount(your_amount_field)"/>

Write the following code inside your class in your py:

from openerp.tools import amount_to_text_en

def onchange_amount(self, cr, uid, ids, amount):
    text_amount = amount_to_text_en.amount_to_text(amount, 'en', 'EURO')
    return {'value': {'text_amount': text_amount}}

Perfect Sudhir !

Serpent Consulting Services Pvt. Ltd.
on 4/9/13, 9:57 AM

Thank you for the compliment.

Sudhir Arya (SA)
on 4/9/13, 9:58 AM

i get an error like File "C:\Program Files\OpenERP 6.0\Server\addons\crm\crm_lead.py", line 180 text_amount = amount_to_text_en.amount_to_text(amount, 'en', 'EURO') ^ IndentationError: expected an indented block..this is the last 3 lines of my error...

selva
on 4/13/13, 4:46 AM

It is just an indentation error. Make sure your code is indented(give tab) properly.

Sudhir Arya (SA)
on 4/13/13, 7:33 AM
0
Anas Gaffar
On 5/23/14, 5:52 PM

See my updated answer.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/9/13, 9:39 AM
Seen: 3955 times
Last updated: 3/16/15, 8:10 AM